summaryrefslogtreecommitdiff
path: root/index.js
diff options
context:
space:
mode:
authorMatthew Kosarek <mattkae@protonmail.com>2021-10-05 07:23:29 -0400
committerMatthew Kosarek <mattkae@protonmail.com>2021-10-05 07:23:29 -0400
commitb1388b40b138e4440cda121b8044b26ae35759ef (patch)
tree121b9ab7d80256f69a7389e8199edae181081282 /index.js
parent2fff4c30c18a1b89c3240222cd915e7607563896 (diff)
Minified images and added better scroll code to the canvas
Diffstat (limited to 'index.js')
-rw-r--r--index.js5
1 files changed, 3 insertions, 2 deletions
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';
}