From 2074f6be3096386fb543f040dec314290f6eb920 Mon Sep 17 00:00:00 2001 From: Matthew Kosarek Date: Wed, 6 Oct 2021 06:18:34 -0400 Subject: Fixed the carousel --- index.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'index.js') diff --git a/index.js b/index.js index 3397c30..72fcc2e 100644 --- a/index.js +++ b/index.js @@ -37,7 +37,8 @@ function runCarousel() { function updateCarousel() { var children = imageContainer.children, - selectedChildPosition = -imageContainer.children[carouselPosition].offsetLeft + 240; + numChildren = imageContainer.children.length, + selectedChildPosition = -(carouselPosition * 240); imageContainer.style.transform = 'translate(' + selectedChildPosition + 'px, 0)'; for (var i = 0; i < children.length; i++) { var image = children[i]; -- cgit v1.2.1