5
我正面臨着一個令人討厭的問題,將Wordpress中的無限滾動插件與使用砌體的主題集成在一起。無限滾動砌體在woocommerce不起作用
我有最新版本的無限滾動,2.6.2的,我已經在插件的回調部分添加以下代碼:
// hide new items while they are loading
var $newElems = jQuery(newElements).css({ opacity: 0 });
// ensure that images load before adding to masonry layout
$newElems.imagesLoaded(function(){
// show elems now they're ready
$newElems.animate({ opacity: 1 });
$container.masonry('appended', $newElems, true);
});
,但它不工作,它增加不透明度爲新元素,但它並沒有增加職位等,所以不太工作;新項目將在舊版產品的頁面頂部進行。
腳本的樣子:
/* <![CDATA[/
var infinite_scroll = "{\"loading\":{\"msgText\":\"Loading...<\\/em>\",\"finishedMsg\":\"No additional products.<\\/em>\",\"img\":\"http:\\/\\/www.test.com\\\/wp-content\\\/plugins\\\/infinite-scroll\\\/img\\\/ajax-loader.gif\"},\"nextSelector\":\".next\",\"navSelector\":\".woo-pagination\",\"itemSelector\":\"li.product\",\"contentSelector\":\"ul.products\",\"debug\":false,\"behavior\":\"\",\"callback\":\"\\\/\\\/ hide new items while they are loading\r\nvar $newElems = jQuery(newElements).css({ opacity: 0 });\r\n\\/\\/ ensure that images load before adding to masonry layout\r\n$newElems.imagesLoaded(function(){\r\n\\/\\/ show elems now they're ready\r\n$newElems.animate({ opacity: 1 });\r\n$container.masonry('appended', $newElems, true);\r\n});\"}";
/]]> */
砌築的樣子:
// Only fire masonry if the window is an appropriate size and images are loaded
jQuery(function(){
var $container = jQuery('ul.products');
$container.imagesLoaded(function(){
if (jQuery(window).width() > 767) {
$container.masonry({
itemSelector : 'li.product',
columnWidth : 295,
isFitWidth: true,
gutterWidth : 2
});
}
});
});