diff --git a/frontend/src/routes/+page.svelte b/frontend/src/routes/+page.svelte index 31d34e7..e4f6a22 100644 --- a/frontend/src/routes/+page.svelte +++ b/frontend/src/routes/+page.svelte @@ -32,6 +32,14 @@ ); } + function backIndex() { + return index - 1 < 0 ? index : index - 1; + } + + function advanceIndex() { + return index + 1 > photoList.length - 1 ? index : index + 1; + } + function swipeCanva(advance) { const width = window.innerWidth / 2; const animTranslate = advance ? [-width, width] : [width, -width]; @@ -46,7 +54,7 @@ duration: 300, easing: "easeInQuad", complete: function () { - index = advance ? index + 1 : index - 1; + index = advance ? advanceIndex() : backIndex(); photoDiv.style.transform = `translateX(${animTranslate[1]}px)`; anime({ targets: photoDiv,