From a0faed92bb6935d5c2a5433d99acde76c20b8520 Mon Sep 17 00:00:00 2001 From: Thomas-git Date: Tue, 18 Dec 2012 19:17:32 +1100 Subject: [PATCH] Animations callback should now fire in all cases In CSS transform animations : Callback will now be fired properly when there is no animation taking place Callback will now be fired even if no elements are visible (due to filtering) So it should behave as with jquery animations. --- jquery.isotope.js | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/jquery.isotope.js b/jquery.isotope.js index f4efad6..cd5773e 100644 --- a/jquery.isotope.js +++ b/jquery.isotope.js @@ -632,6 +632,7 @@ ), animOpts = this.options.animationOptions, onLayout = this.options.onLayout, + noChanged = false, objStyleFn, processor, triggerCallbackNow, callbackFn; @@ -694,7 +695,19 @@ // yeah, this is inexact var duration = parseFloat( getComputedStyle( testElem[0] )[ transitionDurProp ] ); if ( duration > 0 ) { + //We need to track property changed by ourselves + //NOTE : http://stackoverflow.com/questions/9548723/css-transition-event-not-fired-in-jquery-when-there-is-no-property-change + noChanged=true; processor = function( i, obj ) { + + noChanged = noChanged && (obj.$el.length==0 || ( + (!obj.style.translate || (obj.style.translate && obj.style.translate[0]==obj.$el.css('translate')[0] && obj.style.translate[1]==obj.$el.css('translate')[1]) ) && + (!obj.style.opacity || (obj.style.opacity && obj.style.opacity==obj.$el.css('opacity') ) ) && + (!obj.style.scale || (obj.style.scale && obj.style.scale==obj.$el.css('scale') ) ) && + (!obj.style.height || (obj.style.height && obj.style.height==obj.$el.height() ) ) && + (!obj.style.width || (obj.style.width && obj.style.width==obj.$el.width() ) ) + )); + obj.$el[ styleFn ]( obj.style, animOpts ) // trigger callback at transition end .one( transitionEndEvent, callbackFn ); @@ -706,7 +719,8 @@ // process styleQueue $.each( this.styleQueue, processor ); - + triggerCallbackNow=triggerCallbackNow || this.styleQueue.length==0 || noChanged; + if ( triggerCallbackNow ) { callbackFn(); } @@ -1398,4 +1412,4 @@ return this; }; -})( window, jQuery ); \ No newline at end of file +})( window, jQuery );