deploy: fix scroll jump when closing previous story
This commit is contained in:
@@ -301,11 +301,14 @@
|
||||
// Close ALL other story cards globally across all categories
|
||||
const allCards = document.querySelectorAll('.story-card');
|
||||
allCards.forEach(c => {
|
||||
if (c !== card) {
|
||||
if (c !== card && c.classList.contains('open')) {
|
||||
c.classList.remove('open');
|
||||
const b = c.querySelector('.story-body');
|
||||
if (b) {
|
||||
b.style.transition = 'none';
|
||||
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
|
||||
setTimeout(() => {
|
||||
card.scrollIntoView({ behavior: 'smooth', block: 'start' });
|
||||
}, 100);
|
||||
}, 50); // Small delay to allow reflow, works perfectly and instantly
|
||||
} else {
|
||||
card.classList.remove('open');
|
||||
if (body) {
|
||||
|
||||
Reference in New Issue
Block a user