我在我的网站Car Show News
上使用Infinite-Scroll我也在网站上使用Masonry来安排帖子
以下是我用来调用砌体和无限滚动脚本的JavaScript示例...
$(function () {
var $container = $('.main');
$container.imagesLoaded(function () {
$container.masonry({
itemSelector: '.post',
isAnimated: true
});
});
$('.main').infinitescroll({
navSelector: ".post-nav",
nextSelector: ".previous a",
itemSelector: ".post",
loadingImg: "http://b.imagehost.org/0548/Untitled-2.png",
loadingText: "<em></em>",
onPageChange: function (pageNum, pageUrl, scrollOffset) {
path = jQuery('<a/>').attr('href', pageUrl)[0].pathname.replace(/^[^\/]/, '/');
_gaq.push(['_trackPageview', path]);
}
}, function (newElements) {
var $newElems = $(newElements).css({
opacity: 0
});
$newElems.imagesLoaded(function () {
$newElems.animate({
opacity: 1
});
$container.masonry('appended', $newElems, true);
});
var el = document.getElementById('gsocial');
if (typeof gapi !== "undefined") {
gapi.plusone.go(el);
}
if (typeof FB !== "undefined") {
FB.XFBML.parse(el);
}
if (typeof twttr !== "undefined") {
twttr.widgets.load();
}
}); });`
加载社交媒体按钮时,Facebook按钮似乎在向下滚动并使用无限滚动脚本后再次加载所有Facebook按钮...
我需要做些什么来阻止脚本一次又一次地加载Facebook按钮?