我正在将 Masonry 用于项目并相应地应用 imagesLoaded。
经过多次测试后,我发现这两者几乎完美地结合在一起,但有时它们会失败。99% 的情况是 imagesLoaded 的错。
但是,在 Internet Explorer 上,imageLoaded 似乎比在任何其他浏览器中加载失败的次数要多得多。
这是我发现的:
- 如果您打开一个新选项卡并直接输入 URL -> imagesLoaded 作品
- 如果你点击刷新 - > imagesLoaded 作品
- 如果您输入 URL,点击刷新,在地址栏中标记文本并按 Enter -> imagesLoaded 失败
- 如果在控制台打开的情况下重复上述操作 -> imagesLoaded 有效
- 有时如果感觉像它,它就不起作用......
这是怎么回事?这只发生在 Internet Explorer(11、10、9 等)中。
这是JS:
function masonryOptions(){
$('.post-wrapper').width((((($('#content').width() - ((columnCount*gutter) - gutter)) / columnCount) / $('#content').width()) * 100)+'%');
$(window).resize(function() {
$('.post-wrapper').width((((($('#content').width() - ((columnCount*gutter) - gutter)) / columnCount) / $('#content').width()) * 100)+'%');
});
container.imagesLoaded(function(){
$('iframe').load(function() {
container.masonry({
itemSelector: '.post-wrapper',
gutter: gutter,
transitionDuration: 0
});
});
});
}
$(document).ready(function(){
masonryOptions();
});
还有一个演示页面: http: //lorem-blogsum.tumblr.com/