I have a function that animates dom elements with CSS3 if available. Now i often use the :animeted
jQuery selector. How do i make my CSS3 Animated elements respond to :animeted
selector also?
When a DOM Object is animated with jQuery it gets "fxqueue":"inprogress"
in the Data object, so i was thinking i could manually add my elements using:
$("div").eq(0).data({"fxque开发者_开发百科ue": "inprogress"});
but
console.log( $("div:animated") )
does not select anything.
That won't work.
The :animated
filter is defined as
jQuery.expr.filters.animated = function( elem ) {
return jQuery.grep(jQuery.timers, function( fn ) {
return elem === fn.elem;
}).length;
};
It checks whether the element is in jQuery.timers
.
Instead, you can replace the :animated
selector:
var originalAnimated = jQuery.expr.filters.animated;
jQuery.expr.filters.animated = function(elem) {
return originalAnimated(elem) || something;
};
精彩评论