admin管理员组文章数量:1416325
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 pleted. 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.
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 pleted. I've looked through the docs, but all I can find is
Share Improve this question asked Feb 21, 2012 at 15:09 DónalDónal 188k177 gold badges586 silver badges844 bronze badgesSimiliar to a callback, onLayout is a function that will be triggered after every time an Isotope instance runs through its layout logic.
1 Answer
Reset to default 5According to the source code, there is no difference. Three callback functions may be called when layout pletes: the one passed in the final argument to isotope()
, the one passed in the onLayout
option and the one passed in the plete
member of the animationOptions
option.
The relevant parts of the source are:
// [...]
} else if ( callback || onLayout || animOpts.plete ) {
// has callback
var isCallbackTriggered = false,
// array of possible callbacks to trigger
callbacks = [ callback, onLayout, animOpts.plete ],
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.
本文标签: javascriptisotope callback functionsStack Overflow
版权声明:本文标题:javascript - isotope callback functions - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1745251493a2649848.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论