fix: videos and video buttons

This commit is contained in:
Oleksandr 2026-02-17 19:02:00 +02:00 committed by outfoxxed
parent e42985d6e6
commit dff66ef779
Signed by: outfoxxed
GPG key ID: 4C88A185FB89301E
2 changed files with 20 additions and 5 deletions

View file

@ -66,6 +66,8 @@ document.addEventListener("DOMContentLoaded", () => {
};
const updateDimensions = () => {
// capture item width
const oldItemWidth = itemWidth;
itemWidth = container.clientWidth;
if (itemWidth === 0) return;
@ -79,9 +81,15 @@ document.addEventListener("DOMContentLoaded", () => {
item.style.maxWidth = `${itemWidth}px`;
});
targetScrollX =
bufferSize * sequenceWidth +
(targetScrollX % sequenceWidth);
if (oldItemWidth > 0) {
const scrollRatio = targetScrollX / oldItemWidth;
const relativeScroll = scrollRatio % originalCount;
targetScrollX =
(bufferSize * originalCount + relativeScroll) * itemWidth;
} else {
targetScrollX = bufferSize * sequenceWidth;
}
currentScrollX = targetScrollX;
scroller.style.transform = `translateX(-${currentScrollX}px)`;
};