Search code examples
jqueryeasing

How can I detect which easings are available in jQuery?


I am writing a plugin and I need to detect if an easing is avaiable, as referencing one which isn't causes the plugin to fail.

If the easing isn't present, I'm going to fallback to swing.

So, how can I figure this out?


Solution

  • jQuery.easing has them.

    if ('easeOutBounce' in jQuery.easing) {
      // Good to go
    }
    

    Example

    $(this).animate(
        {
             bottom: 0
        },
        {
             duration: 100,
             easing: 'easeOutCubic' in $.easing ? 'easeOutCubic' : 'swing'
        }
    );