简体   繁体   English

jQuery Easing插件无法正常工作

[英]jQuery Easing Plugin not working

Can't seem to get this jQuery easing plugin to work! 似乎无法让这个jQuery缓动插件工作! I saw it on http://easings.net/ and I have a fiddle on http://jsfiddle.net/XqqtN/ with my code 我在http://easings.net/上看到它,我在http://jsfiddle.net/XqqtN/上有一个小提琴,我的代码

I'm new to this please help! 我是新来的,请帮忙!

$("#coolDiv").animate({'top':'-300px'},600,'easeOutBack',function(){ $(this).css({'top':'310px'});

Using the jQuery easing plugin should work: 使用jQuery缓动插件应该工作:

#coolDiv {
    width: 50px;
    height: 50px;
    position: absolute;
    top: 0;
    right: 0;
    background: yellow;
}

<div id="coolDiv">cool</div>

var left = $('#coolDiv').offset().left;

$("#coolDiv").css({left:left}).animate({"left":"0px"}, { duration: 1500, easing: "easeOutBack" });

Note that the main difference is adding { duration: 1500, easing: "easeOutBack" } to the animate function. 请注意,主要区别在于将{duration:1500,easing:“easeOutBack”}添加到a​​nimate函数。

Fiddle 小提琴

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM