2016-07-14 62 views
0

我想在我的平滑滚动代码中添加缓动样式,但每当我这样做时,它都会在控制台中引发持续增加的jquery错误。在转换时添加缓动抛出jquery错误

$('#slider-scrollDown').click(function() { 
    $('html, body').animate({ 
     scrollTop: $("#scrollTo-container").offset().top 
    }, 2000); 
}); 

这是我应得的,我尝试添加像这样的宽松政策:

$('#slider-scrollDown').click(function() { 
    $('html, body').animate({ 
     scrollTop: $("#scrollTo-container").offset().top 
    }, 2000, 'easeInOut'); 
}); 

的错误,我收到的控制台是:

Uncaught TypeError: n.easing[this.easing] is not a function

该款显示器一次,然后在下面的另一个红色增加的数字,它不停止。

+0

删除时间延迟和写easeInOutCubic –

+0

好吧,但这不是真的那种宽松我想用... – Lee

+0

请检查此答案http://stackoverflow.com/questions/12592279/typeerror-p-easingthis- easing-is-not-a-function –

回答

0

这是因为easeInOut不存在......在此页面上的样子;)https://api.jqueryui.com/easings/

+0

如果我使用其中一个列出的例子,比如'easeInOutBack' – Lee

+0

mhhhh ...你试着调试吗?如果添加n.easing [this.easing]完成的断点... n.easing对象中的哪些属性? –

+0

有jquery ** ui **引用? – BenG

-1

嗯试图加载宽松的时候我忽略了一些东西。我没有提到我使用的是Wordpress,而我刚刚发现需要额外的函数调用才能获得jQuery缓动函数。

只需将wp_enqueue_script ('jquery-effects-core');添加到我的负载列表中即可解决问题。

谢谢大家。

+0

亚历克斯,为什么downvote?不要因为我低估了你的答案而失望,这没有帮助! – Lee