gpt4 book ai didi

scroll - 使用 Tumblr Like Button 和无限滚动

转载 作者:行者123 更新时间:2023-12-04 22:47:55 26 4
gpt4 key购买 nike

我正在尝试使用 Infinite Scroll 中的新 Tumblr like 按钮(允许您的主题在主页上的单个 Tumblr 帖子上使用类似按钮)它们适用于第一个“页面”的前 15 个帖子,但一旦它加载另一个页面喜欢按钮停止工作。这些是 Tumblr 在文档页面上给出的说明:

Function: Tumblr.LikeButton.get_status_by_page(n)
Description: Call this function after requesting a new page of Posts. Takes the page number that was just loaded as an integer.

Function: Tumblr.LikeButton.get_status_by_post_ids([n,n,n])
Description: Request Like status for individual posts. Takes an array of post IDs.



由于我不确定如何正确应用 JQuery 我不确定在哪里添加这些函数,这是我当前主题的 JS:
    // MASONRY
var $container = $('#content');

$container.imagesLoaded( function(){
$container.masonry({
itemSelector: '.entry',
columnWidth: 220
});
});

// INFINITE SCROLL
$container.infinitescroll({
navSelector : '#pagination',
nextSelector : '#pagination li a.pagination_nextlink',
itemSelector : '.entry',
loading: {
img: 'http://static.tumblr.com/glziqhp/K37m9yaub/257__1_.gif'
}
},

function( newElements ) {
var $newElems = $( newElements ).css({
opacity: 0
});
$newElems.imagesLoaded(function(){
$newElems.animate({
opacity: 1
});
$container.masonry(
'appended', $newElems, true
);
});
});

最佳答案

首先,您需要为每个帖子添加一个唯一的帖子 ID:

<div class="entry masonry-brick" id="{PostID}">...</div>

文档提到在附加/加载新帖子(或新页面)后请求类似状态:

function( newElements ) {
var $newElems = $( newElements ).css({
opacity: 0
});

// Create Array of $newElems IDs
var $newElemsIDs = $newElems.map(function () {
return this.id;
}).get();

$newElems.imagesLoaded(function(){
$newElems.animate({
opacity: 1
});
$container.masonry(
'appended', $newElems, true
);

// Let's just see what we have, remove console.log() if working
console.log($newElems, $newElemsIDs);


Tumblr.LikeButton.get_status_by_post_ids($newElemsIDs);
});
});

我希望这为您指明了正确的方向。

关于scroll - 使用 Tumblr Like Button 和无限滚动,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16390193/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com