在 isotope onLayout 中定义/调用函数
我正在使用 http://isotope.metafizzy.co/docs/options.html#onlayout 它这样说:
“与回调类似,onLayout 是一个函数,每次同位素实例运行其布局逻辑时都会触发该函数。”
$('#container').isotope({
onLayout: function( $elems ) {
// `this` refers to jQuery object of the container element
console.log( this.height() );
// callback provides jQuery object of laid-out item elements
$elems.css({ background: 'blue' });
}
});
这意味着当“Layout”完成时我可以运行这个:
$elems.css({ background: 'blue' });
我没有“$elems”,但据我所知,这意味着当“onLayout”完成时我可以运行我想要的东西并且我想运行this:
$("#container").width();
$("#head").animate({ width: newWidth}, "fast");
但是“( )”中的“$elems”如何以及是什么?
谢谢
I'm using http://isotope.metafizzy.co/docs/options.html#onlayout and it says this:
"Similiar to a callback, onLayout is a function that will be triggered after every time an Isotope instance runs through its layout logic."
$('#container').isotope({
onLayout: function( $elems ) {
// `this` refers to jQuery object of the container element
console.log( this.height() );
// callback provides jQuery object of laid-out item elements
$elems.css({ background: 'blue' });
}
});
That means that when "Layout" has finished i can run this:
$elems.css({ background: 'blue' });
I don't have "$elems" but from what i can understand that means that when "onLayout" has finished i can run what i want and I would like to run this:
$("#container").width();
$("#head").animate({ width: newWidth}, "fast");
But how and what is "$elems" inside the "( )" ?
Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以将自定义事件绑定到元素上,如下所示:
然后使用
.trigger()
调用它:我认为,使用此功能,您应该能够非常轻松地设置您想要的内容。
更新:
而不是调用此代码:
调用此:
You can bind custom events on to elements like so:
And then call it with
.trigger()
:Using this, you should be able to set up what you want pretty easily, I think.
Update:
Instead of calling this code:
Call this: