jQuery插件Isotope的回调 [英] Callback for jquery plugin Isotope

查看:80
本文介绍了jQuery插件Isotope的回调的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


我正在使用具有可扩展项的同位素( http://isotope.metafizzy.co ),我想使用ScrollTo,以便我可以自动滚动到新展开的项目.


I'm using isotope ( http://isotope.metafizzy.co ) with expandable items, and i would like to use ScrollTo so that i can automatically scroll to the newly expanded item..

我首先尝试使用带有reLayout方法的回调,例如:

I first tried to use the callback with the reLayout method, something like:

container.isotope('reLayout', iwannascroll(origin));

function iwannascroll(origin_with_newpos){
    $.scrollTo(origin_with_newpos, 800);                
}

origin是一个变量,我在其中将点击处理程序中的"this"放入其中.
不幸的是,我总是得到物体的旧位置.

origin being a variable where i put "this" from the click handler.
Unfortunately, i always get the old position of the object..

实际上,我不确定回调是否被调用太早或者是否无法理解如何存储jQuery对象使它更像是副本或指针";-)

Actually i'm not sure if the callback is called too soon or if i'm unable to understand how storing my jQuery object makes it more like a copy or a "pointer" ;-)

有什么想法吗?

我现在确定在动画结束之前调用了回调,所以我的问题是:现在如何完成动画?

EDIT : i am now sure that the callback is called before the end of the animation, so my question would be : how can i now the animation has finished ?

推荐答案

同位素重新布局的回调确实触发得太早了.

The callback for the Isotope reLayout fires too soon indeed.

我使用bind来检测动画何时结束.

I used bind to detect when the animation ended.

它同时适用于jquery和css动画引擎.

It works works for both the jquery and css animation engine.

$("#isotope").bind("transitionend webkitTransitionEnd oTransitionEnd MSTransitionEnd", function(){

});

ps:当然,这必须放在常规同位素代码之后.

ps: this has to be placed after the regular isotope code of course.

问候, 曼努埃尔

这篇关于jQuery插件Isotope的回调的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆