jQuery Masonry回调不工作 [英] jQuery Masonry callback not working

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

问题描述



基本上,我试图防止未定时的内容的闪光,但是我想尝试在jQuery Masonry完成其定位魔术时获取一个回调函数。

  var $ jigsaw = $(可选)为了测试的目的, '#拼图'); 

$ jigsaw.imagesLoaded(function(){
$ jigsaw.masonry({
columnWidth:180,
isAnimated:!Modernizr.csstransitions,
isResizable:true,
itemSelector:'.piece'
},function(){
alert('Completed');
});

我可能会遗漏一些明显的东西,但任何帮助将不胜感激。




但是回调是非常棒的同位素 v1.5!



原因是你可能会使用CSS转换或者CSS转换, jQuery动画或两者。所以我需要构建所有的逻辑来检测哪个正在使用,然后什么时候触发实际的回调。


I cam trying to get a callback function to execute when jQuery Masonry has done its positioning magic.

Basically I am trying to prevent the flash of unstyled content. For the purpose of testing though I am using a simple alert that isn't called at all.

var $jigsaw = $('#jigsaw');

$jigsaw.imagesLoaded( function(){
    $jigsaw.masonry({
     columnWidth : 180,
      isAnimated : !Modernizr.csstransitions,
     isResizable : true,
    itemSelector : '.piece'
    }, function(){
        alert('Completed');
    });
});

I may be missing something obvious, but any help would be appreciated

解决方案

Callbacks with Masonry v2.0 are undocumented and not quite supported.

But callbacks are awesome with Isotope v1.5! If you want proper callbacks that trigger after the end of a transition or animation, Isotope is the way to go.

The reason being is that you might be using CSS transitions or jQuery animation or neither. So I'd need to build in all the logic to detect which one is being used and then when to trigger the actual callback.

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

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