fix: 🐛 calculate end of gallery track correctly in all browsers

This commit is contained in:
Sebin Nyshkim 2025-04-10 20:45:51 +02:00
parent cbc41e74ba
commit 8c21edac0e

View file

@ -19,15 +19,15 @@
}); });
}; };
const progress = ({ target: { scrollLeft, scrollLeftMax } }) => { const progress = ({ target: { scrollLeft, scrollWidth, offsetWidth } }) => {
galleryIndicator.style.width = `${(scrollLeft / scrollLeftMax) * 100}%`; galleryIndicator.style.width = `${(scrollLeft / (scrollWidth - offsetWidth)) * 100}%`;
}; };
const isAtEnd = () => { const isAtEnd = () => {
galleryTrack.scrollLeft === 0 galleryTrack.scrollLeft <= 0
? (galleryPrevious.disabled = true) ? (galleryPrevious.disabled = true)
: (galleryPrevious.disabled = false); : (galleryPrevious.disabled = false);
galleryTrack.scrollLeft === galleryTrack.scrollLeftMax galleryTrack.scrollLeft >= galleryTrack.scrollWidth - galleryTrack.offsetWidth
? (galleryNext.disabled = true) ? (galleryNext.disabled = true)
: (galleryNext.disabled = false); : (galleryNext.disabled = false);
}; };