[英]What variables to use in jQuery easing animation
I'm using the grayscale bootstrap template for a wordpress theme. 我正在为Wordpress主题使用灰度引导模板。 I have my scripts enqueued, but I'm not sure how to fix the syntax on the original javascript.
我的脚本排队了,但是我不确定如何在原始javascript上修复语法。 The functionality works like this: click on a link and it slides you down to the id attribute.
该功能的工作方式如下:单击链接,然后将您滑到id属性。 Here is the original code:
这是原始代码:
$(function() {
$('.page-scroll a').bind('click', function(event) {
var $anchor = $(this);
$('html, body').stop().animate({
scrollTop: $($anchor.attr('href')).offset().top
}, 1500, 'easeInOutExpo');
event.preventDefault();
});
});
And I replace the $ with jQuery
because of .NoConflict 而且由于.NoConflict,我用
jQuery
替换了$
jQuery(function() {
jQuery('.page-scroll a').bind('click', function(event) {
var $anchor = jQuery(this);
jQuery('html, body').stop().animate({
scrollTop: jQuery($anchor.attr('href')).offset().top
}, 1500, 'easeInOutExpo');
event.preventDefault();
});
});
Then I get this error: 然后我得到这个错误:
TypeError: 'undefined' is not a function (evaluating 'x.easing[this.easing] (e,this.options.duration*e,0,1,this.options.duration)')
The $anchor is local, so I'm sure it doesn't matter. $ anchor是本地的,所以我确定这没关系。 Infact I've replced it also, but I get the same result.
实际上,我也已经采用了它,但是我得到了相同的结果。 Any suggestions?
有什么建议么? Does the problem lie in this line
var anchor = jQuery(this);
问题是否出在这行
var anchor = jQuery(this);
? ?
It turns out I was loading the wrong library. 原来我加载了错误的库。 I needed to load the easing library instead of the jQuery UI library.
我需要加载缓动库而不是jQuery UI库。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.