From b1388b40b138e4440cda121b8044b26ae35759ef Mon Sep 17 00:00:00 2001 From: Matthew Kosarek Date: Tue, 5 Oct 2021 07:23:29 -0400 Subject: Minified images and added better scroll code to the canvas --- index.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'index.js') diff --git a/index.js b/index.js index 4d29466..3397c30 100644 --- a/index.js +++ b/index.js @@ -36,7 +36,9 @@ function runCarousel() { } function updateCarousel() { - var children = imageContainer.children; + var children = imageContainer.children, + selectedChildPosition = -imageContainer.children[carouselPosition].offsetLeft + 240; + imageContainer.style.transform = 'translate(' + selectedChildPosition + 'px, 0)'; for (var i = 0; i < children.length; i++) { var image = children[i]; if (i !== carouselPosition) { @@ -52,7 +54,6 @@ function runCarousel() { } } - imageContainer.style.left = 'calc(' + (-carouselPosition * 252) + 'px + 50% - 120px)'; rightButton.style.visibility = (carouselPosition === numImages - 1) ? 'hidden' : 'visible'; leftButton.style.visibility = (carouselPosition === 0) ? 'hidden' : 'visible'; } -- cgit v1.2.1