fix: make sure setActiveImage gets integer value after scroll
This commit is contained in:
parent
a0182fe447
commit
6b0acce446
1 changed files with 4 additions and 2 deletions
|
@ -49,7 +49,9 @@ const next = (): void => {
|
|||
};
|
||||
|
||||
const onScroll = (): void => {
|
||||
const newImg = getActiveImage(galleryViewport.value, galleryItemWidth.value);
|
||||
const newImg = Math.floor(
|
||||
getActiveImage(galleryViewport.value, galleryItemWidth.value)
|
||||
);
|
||||
setActiveImage(newImg);
|
||||
};
|
||||
|
||||
|
@ -58,7 +60,7 @@ onMounted(() => {
|
|||
images.value = Array.from(galleryViewport.value.children);
|
||||
galleryItemWidth.value =
|
||||
galleryViewport.value.scrollWidth / images.value.length;
|
||||
galleryViewport.value.addEventListener("scroll", debounce(onScroll, 100));
|
||||
galleryViewport.value.addEventListener("scroll", debounce(onScroll, 500));
|
||||
});
|
||||
</script>
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue