Browse Source

add Isotope._noTransition; bit o' refactor

pull/726/head
David DeSandro 11 years ago
parent
commit
60ec752e2e
  1. 45
      js/isotope.js

45
js/isotope.js

@ -225,17 +225,16 @@ function isotopeDefinition( Outlayer, getSize, matchesSelector, Item, LayoutMode
}
}
// HACK
// disable transition if instant
var _transitionDuration = this.options.transitionDuration;
if ( this._isInstant ) {
this.options.transitionDuration = 0;
var _this = this;
function hideReveal() {
_this.reveal( hiddenMatched );
_this.hide( visibleUnmatched );
}
this.reveal( hiddenMatched );
this.hide( visibleUnmatched );
// set back
if ( this._isInstant ) {
this.options.transitionDuration = _transitionDuration;
this._noTransition( hideReveal );
} else {
hideReveal();
}
return matches;
@ -479,12 +478,9 @@ function isotopeDefinition( Outlayer, getSize, matchesSelector, Item, LayoutMode
};
Isotope.prototype._filterRevealAdded = function( items ) {
// disable transition for filtering
var transitionDuration = this.options.transitionDuration;
this.options.transitionDuration = 0;
var filteredItems = this._filter( items );
// re-enable transition for reveal
this.options.transitionDuration = transitionDuration;
var filteredItems = this._noTransition( function() {
return this._filter( items );
});
// layout and reveal just the new items
this.layoutItems( filteredItems, true );
this.reveal( filteredItems );
@ -521,6 +517,25 @@ function isotopeDefinition( Outlayer, getSize, matchesSelector, Item, LayoutMode
}
};
/**
* trigger fn without transition
* kind of hacky to have this in the first place
* @param {Function} fn
* @returns ret
* @private
*/
Isotope.prototype._noTransition = function( fn ) {
// save transitionDuration before disabling
var transitionDuration = this.options.transitionDuration;
// disable transition
this.options.transitionDuration = 0;
// do it
var returnValue = fn.call( this );
// re-enable transition for reveal
this.options.transitionDuration = transitionDuration;
return returnValue;
};
// ----- ----- //
return Isotope;

Loading…
Cancel
Save