javascript - How to use inline easing with ScrollTo plug-in -
i try use scrollto plug-in easing effect.
and don't want include easing plug-in file, because use once , 1 easing effect.
this 'easeoutback' want 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 scrollto's function code like..
$(window).scrollto(element,800,{offset:-80,onafter:function(){ alert('done'); }});
so try insert 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] not function
you can store 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 can use when easing plugin loaded.
passing function directly doesn't work because jquery's animate()
accepts string easing function (which looked in $.easing
).
Comments
Post a Comment