Search code examples
jqueryjquery-easing

How do I check if a specific jquery-easing method is defined?


I have a jQuery plugin. One of the options is what easing method to use for animations. I want to be able to check if the easing method is defined, before I go on and call the $.animate(...) function with the specified easing method. Like so:

var easingMethod = option.easing;
if (!IsDefined(easingMethod)) easingMethod = 'linear';

What would be IsDefined() function?

I could do if (typeof(easingMethod)==undefined) but typeof(easingMethod)==='string'. I'm thinking more along the lines of

function isDefined(s) {
   // If a method named 's' is defined, return true, else false
}

And I have no idea how to do that.


Solution

  • How about this?

    function isDefined(s) {
      return $.easing.hasOwnProperty(s);
    }