我正在尝试让tumblr的喜欢按钮工作与无限滚动
下面是我的代码不能工作。
And after是有效的代码。
我不熟悉Javascript,所以我不知道如何将它们网格化,使其工作
function( newElements ) {
var $newElems = $(newElements);
$newElems.hide();
$newElems.imagesLoaded(function(){
$wall.masonry( 'appended', $newElems,{isAnimated: false}, function() {
$newElems.fadeIn('fast');
});
});
});
$('#posts').show(0);
});
这里一个可以
function(newElements){
var $newElems = $(newElements).css("opacity","0").css("pointer-events","none");
$('.photoset-grid').photosetGrid({highresLinks: true,rel: $('.photoset-grid').attr('data-id'),gutter: '5px',onComplete: function(){}});
$('.photoset-grid,.lightbox').each(function() {
$(this).magnificPopup({delegate: 'a',type: 'image',gallery:{enabled:true},removalDelay: 200,mainClass: 'mfp-fade'});
});
var $newElemsIDs = $newElems.map(function (){return this.id;}).get();
$newElems.imagesLoaded(function(){
$newElems.css("opacity","1").css("pointer-events","auto");
$K.masonry('appended',$newElems,true);
console.log($newElems,$newElemsIDs);
Tumblr.LikeButton.get_status_by_post_ids($newElemsIDs);
});
});
谢谢你的帮助。
编辑:my full code
$(window).load(function(){
var $wall = $('#posts');
$wall.imagesLoaded(function(){
$wall.masonry({
itemSelector: '.entry, .entry_photo',
isAnimated : false
});
});
$wall.infinitescroll({
navSelector : '#pagination',
nextSelector : '#pagination a',
itemSelector : '.entry, .entry_photo',
bufferPx : 2000,
debug : false,
errorCallback: function() {
$('#infscr-loading').fadeOut('normal');
}},
function( newElements ) {
var $newElems = $( newElements );
$newElems.hide();
$newElems.imagesLoaded(function(){
$wall.masonry( 'appended', $newElems,{isAnimated: false}, function() {$newElems.fadeIn('fast');} );
});
}); $('#posts').show(0);
});
function( newElements ) {
var $newElems = $(newElements);
// Get IDs for new Elements
var $newElemsIDs = $newElems.map(function (){return this.id;}).get();
$newElems.hide();
// Tell Tumblr we need new LikeButton statuses
Tumblr.LikeButton.get_status_by_post_ids($newElemsIDs);
$newElems.imagesLoaded(function(){
$wall.masonry( 'appended', $newElems,{isAnimated: false}, function() {
$newElems.fadeIn('fast');
});
});
$('#posts').show(0);
});