I try to use ScrollTo plug-in with some easing effect.
And I don't want to include easing plug-in file, because I will use only once and only one easing effect.
This 'easeOutBack' I want to use :
easeOutBack: function (x, t, b, c, d, s) {
if (s == undefined) s = 1.70158;
return c*((t=t/d-1)*t*((s+1)*t + s) + 1) + b;
}
And my scrollTo's function code like..
$(window).scrollTo(element,800,{offset:-80,onAfter:function(){
alert('done');
}});
So I try to insert a easing effect like...
$(window).scrollTo(element,800,{offset:-80,
easing:function(x, t, b, c, d){
return -c/2 * (Math.cos(Math.PI*t/d) - 1) + b;
},
onAfter:function(){
alert('done');
}});
It dosn't work.
TypeError: b.easing[this.easing] is not a function
You can simply store the easing function in $.easing
:
$.easing.easeOutBack = function(x, t, b, c, d, s) {
if(s == undefined) s = 1.70158;
return c * ((t = t / d - 1) * t * ((s + 1) * t + s) + 1) + b;
};
After that you can use it just like you would do when the easing plugin is loaded.
Passing the function directly doesn't work because jQuery's animate()
only accepts a string for the easing function (which is looked up in $.easing
).