0

I'm trying to pass my own function into a jquery animation to create my own easing function. This code is written in coffeescript and is actually called, but does not perform an easing function. It merely acts like a callback function. Has anyone else experienced this?

    easing : (x, t, b, c, d) -> 

        if ((t/=d) < (1/2.75))
            return c*(7.5625*t*t) + b

        else if (t < (2/2.75))
            return c*(7.5625*(t-=(1.5/2.75))*t + .75) + b

        else if (t < (2.5/2.75))
            return c*(7.5625*(t-=(2.25/2.75))*t + .9375) + b

        else
            return c*(7.5625*(t-=(2.625/2.75))*t + .984375) + b

    show : () =>

        @container.slideDown @config.animationTime, @easing(), () =>

            @config.visible = true
JonMorehouse
  • 1,313
  • 6
  • 14
  • 34

1 Answers1

1

From the fine manual:

As of jQuery 1.4.3, an optional string naming an easing function may be used.

So the easing argument should be a string which names the easing to use, not an easing function itself. Furthermore, this is a method call:

@easing()

while this is a reference to your easing function:

@easing

If you want to define a custom easing, you have to do it globally by adding a property to $.easing:

$.easing.whatever = (x, t, b, c, d) ->
    #...

and then you reference it by name:

@container.slideDown @config.animationTime, 'whatever', () => ...
mu is too short
  • 426,620
  • 70
  • 833
  • 800