deploy: fix scroll jump when closing previous story

This commit is contained in:
2026-05-27 14:31:24 +00:00
parent e727ed35a9
commit 2969648aa1
+5 -2
View File
@@ -301,11 +301,14 @@
// Close ALL other story cards globally across all categories // Close ALL other story cards globally across all categories
const allCards = document.querySelectorAll('.story-card'); const allCards = document.querySelectorAll('.story-card');
allCards.forEach(c => { allCards.forEach(c => {
if (c !== card) { if (c !== card && c.classList.contains('open')) {
c.classList.remove('open'); c.classList.remove('open');
const b = c.querySelector('.story-body'); const b = c.querySelector('.story-body');
if (b) { if (b) {
b.style.transition = 'none';
b.style.maxHeight = '0px'; b.style.maxHeight = '0px';
b.offsetHeight; // Force reflow
b.style.transition = ''; // Restore transition for next open
} }
} }
}); });
@@ -318,7 +321,7 @@
// Smoothly scroll the newly opened story card to the top of the viewport // Smoothly scroll the newly opened story card to the top of the viewport
setTimeout(() => { setTimeout(() => {
card.scrollIntoView({ behavior: 'smooth', block: 'start' }); card.scrollIntoView({ behavior: 'smooth', block: 'start' });
}, 100); }, 50); // Small delay to allow reflow, works perfectly and instantly
} else { } else {
card.classList.remove('open'); card.classList.remove('open');
if (body) { if (body) {