0
這裏是一個現有的函數滾動到我的div錨點,但我想用easing,而不是如何編輯這個添加,我已經嘗試了幾件事情但沒有奏效如何添加easing到這個動畫
我想這
$.fn.anchorAnimate.defaults = {
speed: 600,
offset: -65,
easing:"easeOutCubic"
};
下面是現有功能
(function ($) {
$.fn.anchorAnimate = function(options) {
var settings = $.extend({}, $.fn.anchorAnimate.defaults, options);
return this.each(function() {
var caller = this;
$(caller).click(function(event) {
event.preventDefault();
var elementClick = $(caller).attr("href");
var destination = $(elementClick).offset().top + settings.offset;
$("html:not(:animated), body:not(:animated)").animate({ scrollTop: destination}, settings.speed, function() {
if(0 === settings.offset) {
window.location.hash = elementClick;
}
});
return false;
});
});
};
$.fn.anchorAnimate.defaults = {
speed: 600,
offset: -65
};
}(jQuery));
您是否嘗試過使用動畫的寬鬆選項? .animate(properties [,duration] [,easing] [,complete]) –