I'm stumped trying to build this jQuery plug-in. The part I'm having trouble with is getting the custom callback function to fire.
(function( $, window, document, undefined ) {
// Function options
var methods = {
init : function( options ) {
return this.each(function (){
methods.start(this, options);
});
},
start : function( el, options ) {
// Attach animationstart to selector
$(document).on("animationstart", el, function(){
options.start.call();
});
}
}
// Plug-in code
$.fn.plugin = function( options ) {
if ( methods[options] ) {
return methods[options].apply( this, Array.prototype.slice.call( arguments, 1 ));
} else if ( typeof options === "object" || ! options ) {
return methods.init.apply( this, arguments );
} else {
$.error( "Method" + options + " does not exist in plugin" );
}
};
})( jQuery );
// Attach to DOM object
$('img').plugin({
'start' : function(){
console.log('Animation started');
}
});
Can anyone help me figure out why 'start' isn't firing the custom callback function?
animationstartevent - Explosion Pills