fix: #14061, world.js show more buttons on infinite scroll

This commit is contained in:
Julian Lam
2026-03-05 12:15:22 -05:00
parent 9bc1b40078
commit 0aead782ab

View File

@@ -77,6 +77,7 @@ define('forum/world', [
$(listEl).append(html); $(listEl).append(html);
html.find('.timeago').timeago(); html.find('.timeago').timeago();
handleImages(); handleImages();
handleShowMoreButtons();
callback(); callback();
}); });
}); });
@@ -216,23 +217,32 @@ define('forum/world', [
} }
feedEl.querySelectorAll('[component="post/content"]').forEach((el) => { feedEl.querySelectorAll('[component="post/content"]').forEach((el) => {
const initted = el.getAttribute('data-showmore');
if (parseInt(initted, 10) === 1) {
return;
}
if (el.clientHeight < el.scrollHeight - 1) { if (el.clientHeight < el.scrollHeight - 1) {
el.parentNode.querySelector('[component="show/more"]').classList.remove('hidden'); el.parentNode.querySelector('[component="show/more"]').classList.remove('hidden');
el.classList.toggle('clamp-fade-6', true); el.classList.toggle('clamp-fade-6', true);
} }
el.setAttribute('data-showmore', '1');
}); });
feedEl.addEventListener('click', (e) => { if (parseInt(feedEl.getAttribute('data-showmore'), 10) !== 1) {
const subselector = e.target.closest('[component="show/more"]'); feedEl.addEventListener('click', (e) => {
if (subselector) { const subselector = e.target.closest('[component="show/more"]');
const postContent = subselector.closest('.post-body').querySelector('[component="post/content"]'); if (subselector) {
const isShowingMore = parseInt(subselector.getAttribute('ismore'), 10) === 1; const postContent = subselector.closest('.post-body').querySelector('[component="post/content"]');
postContent.classList.toggle('line-clamp-6', isShowingMore); const isShowingMore = parseInt(subselector.getAttribute('ismore'), 10) === 1;
postContent.classList.toggle('clamp-fade-6', isShowingMore); postContent.classList.toggle('line-clamp-6', isShowingMore);
$(subselector).translateText(isShowingMore ? '[[world:see-more]]' : '[[world:see-less]]'); postContent.classList.toggle('clamp-fade-6', isShowingMore);
subselector.setAttribute('ismore', isShowingMore ? 0 : 1); $(subselector).translateText(isShowingMore ? '[[world:see-more]]' : '[[world:see-less]]');
} subselector.setAttribute('ismore', isShowingMore ? 0 : 1);
}); }
});
feedEl.setAttribute('data-showmore', '1');
}
} }
function updateDropdowns(modified_cids, state) { function updateDropdowns(modified_cids, state) {
@@ -261,6 +271,7 @@ define('forum/world', [
feedEl.prepend(...html); feedEl.prepend(...html);
handleImages(); handleImages();
handleShowMoreButtons();
} }
return World; return World;