无法获得jQuery砌体 +无限滚动在Safari和Chrome上工作
-
25-10-2019 - |
题
嗨,我正在尝试使用JQuery Masonry和Infinite Scroll设置网站,但我似乎无法在OSX上使用Chrome或Safari工作。
开发网站是 http://bit.ly/hyj3cq
我没有在控制台中遇到任何JavaScript错误。
我尝试过的事情:
- 设置砖石部内图像宽度/高度
- 使用较旧的jQuery库
- 将JS移到头而不是页脚
- 将type =“ text/javascript”添加到脚本标签
- 验证HTML
- 更改jQuery(window).load(和jquery(document)。
这是我正在使用的代码,它与正常工作的演示代码非常相似:
jQuery(window).load(function(){
jQuery('.hfeed').masonry({
singleMode: true,
itemSelector: '.box'
});
jQuery('.hfeed').infinitescroll({
navSelector : '.pagination', // selector for the paged navigation
nextSelector : '.pagination .next', // selector for the NEXT link (to page 2)
itemSelector : '.box', // selector for all items you'll retrieve
loadingImg : '/wp-content/themes/sprppl/images/loader.gif',
loadingText : "Loading...",
donetext : 'No more pages to load.',
debug: false,
errorCallback: function() { jQuery('#infscr-loading').animate({opacity: .8},2000).fadeOut('normal'); }
},
// call masonry as a callback
function( newElements ) { jQuery(this).masonry({ appendedContent: jQuery( newElements ) }); }
);
});
任何帮助将不胜感激。
解决方案
http://desandro.com/demo/masonry/docs/infinite-scroll.html
看看“ Tumblr问题”。您应该设置图像大小标签(在 <img/>
不是 <div/>
)或使用settimeout()
// call masonry as a callback, after 1000 milliseconds
function( newElements ) {
setTimeout(function() {
$wall.masonry({ appendedContent: $(newElements) });
}, 1000);
}
我想,您也应该设置列(我不知道脚本,但这就是他们在文档中所说的)
不隶属于 StackOverflow