2013-05-14 157 views
0

我在jQuery中的.animate函数遇到问题,并将它与缓动混合在一起。jQuery。动画缓动问题

以下工作;

$("#PanelOne").mouseover(function() { 
     $("#PanelTwo").stop(true, false).animate({ marginLeft: "420px"}, 150); 

}); 

但是这并不是;

$("#PanelOne").mouseover(function() { 
     $("#PanelTwo").stop(true, false).animate({ marginLeft: "420px"}, 150, 'easeOutQuint'); 

}); 

我不知道到底是什么我做错了,这将是令人眼花缭乱的东西很明显,但我从来没有使用缓解或之前jQueryUI的,所以我敢输了!

编辑:我在这里引用jQueryUI;

http://ajax.googleapis.com/ajax/libs/jqueryui/1.7.2/jquery-ui.js

+0

是否包含在jQuery UI的影响? http://jqueryui.com/download/ – Yeronimo 2013-05-14 13:54:08

+0

来自文档:“jQuery库中唯一的缓动实现是默认的,称为swing,并且以恒定的速度前进,称为线性。更多的缓动函数可用于使用插件,特别是jQuery UI套件。“ – j08691 2013-05-14 13:56:20

+0

Works here:http://jsfiddle.net/4vCjn/ – 2013-05-14 13:58:02

回答

0

你的代码似乎工作得很好。

确保您已下载包含此效果的jQuery-UI。检查此影响下,在这里:http://jqueryui.com/download/

+0

是的,我现在看到这将如何帮助! – 2013-05-14 14:11:35

+0

我是从谷歌引用库,但必须有错误的地址,我没有从jQueryui.com引用它,它工作正常。谢谢! – 2013-05-14 14:25:34

+0

很高兴帮助你。 – Broxzier 2013-05-14 14:45:33

0

我有我的代码匹配你的,希望这将是有益的。在V ..

<!DOCTYPE html> 
<html> 
<head> 
    <style> 
    div { background:yellow; border:1px solid #AAA; width:80px; height:80px; margin:0 5px; float:left; } 
    div.colored { background:green; } 
    </style> 
    <script src="http://code.jquery.com/jquery-1.9.1.js"></script> 
</head> 
<body> 
    <div id="PanelOne"><img src="http://www.clipartguide.com/_small/0808-0710-1516-1324.jpg" width="85px" height="81px"></div> 
    <div id="mover"><img src="http://www.alissweettreats.com/i//Smiley_Face.jpg" width="85px" height="81px"></div> 
    <div><img src="download2.jpg" width="85px" height="81px"></div> 
<script> 

    $("#run").click(function(){ 
     $("div:animated").toggleClass("colored"); 
    }); 
    function animateIt() { 
     $("#mover").slideToggle("slow", animateIt); 
    } 
    animateIt(); 

    $("#PanelOne").mouseover(function() { 
    alert('Its Working'); 
     $("#mover").stop(true, false).animate({ marginLeft: "420px"}, 150, "easeOutQuint"); 
     }); 
</script> 

</body> 
</html>