1

This is my animation:

elem.animate({ left: stepLeft + "px" }, timing, "MyOwnEasingFunction", function () {
    // somethings
});

and I want to replace MyOwnEasingFunction with my own function, which use this easing:

$.easing.bw = function(x, t, b, c, d) {
    ts=(t/=d)*t;
    tc=ts*t;
    return b+c*(25.8*tc*ts + -78.5*ts*ts + 89.6*tc + -47.4*ts + 11.50*t);   
}

but how can I call it?

markzzz
  • 47,390
  • 120
  • 299
  • 507

2 Answers2

1

Looking at jQuery easing function — variables' comprehension it would be in the following format

$.extend(jQuery.easing,{MyOwnEasingFunction:function(x, t, b, c, d) {
    ts=(t/=d)*t;
    tc=ts*t;
    return b+c*(25.8*tc*ts + -78.5*ts*ts + 89.6*tc + -47.4*ts + 11.50*t);   
}});

elem.animate({ left: stepLeft + "px" }, timing, "MyOwnEasingFunction", function () {
   // somethings
});

Fiddle here: http://fiddle.jshell.net/mme7dhx8/

Community
  • 1
  • 1
r8n5n
  • 2,059
  • 17
  • 23
0
elem.animate({ left: stepLeft + "px" }, timing, function(x, t, b, c, d) {
        ts=(t/=d)*t;tc=ts*t;return b+c*(25.8*tc*ts + -78.5*ts*ts + 89.6*tc + -47.4*ts + 11.50*t);   
    }, function () {
        // somethings
    });
Dimag Kharab
  • 4,439
  • 1
  • 24
  • 45
  • Uhm... in a more "fancy" way? Such as using "MyOwnEasingFunction"? Or just MyOwnEasingFunction() maybe? – markzzz Nov 14 '14 at 12:01