Reputation: 187499
Isotope provides two places where you can supply callback functions:
container.isotope({
itemSelector: itemSelector,
layoutMode: 'fitRows',
onLayout: function() {alert('onLayout callback')}
}, function() {alert('anon callback')});
I don't know what the difference between these two are - they both seem to be called exactly once, after the layout has completed. I've looked through the docs, but all I can find is
Similiar to a callback, onLayout is a function that will be triggered after every time an Isotope instance runs through its layout logic.
Upvotes: 3
Views: 5597
Reputation: 262919
According to the source code, there is no difference. Three callback functions may be called when layout completes: the one passed in the final argument to isotope()
, the one passed in the onLayout
option and the one passed in the complete
member of the animationOptions
option.
The relevant parts of the source are:
// [...]
} else if ( callback || onLayout || animOpts.complete ) {
// has callback
var isCallbackTriggered = false,
// array of possible callbacks to trigger
callbacks = [ callback, onLayout, animOpts.complete ],
instance = this;
triggerCallbackNow = true;
// trigger callback only once
callbackFn = function() {
if ( isCallbackTriggered ) {
return;
}
var hollaback;
for (var i=0, len = callbacks.length; i < len; i++) {
hollaback = callbacks[i];
if ( typeof hollaback === 'function' ) {
hollaback.call( instance.element, $elems );
}
}
isCallbackTriggered = true;
};
// [...]
}
As you can see, an array is built with the three potential callbacks, and callbackFn()
calls each one in sequence if it's a function.
Upvotes: 5