Skip to content

Commit

Permalink
Fixed bug with state management in CarouselGallery
Browse files Browse the repository at this point in the history
  • Loading branch information
Nrosa01 committed Jun 9, 2023
1 parent 4d825c0 commit 0b801f0
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
12 changes: 11 additions & 1 deletion src/lib/CarouselGallery.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@
}
function handleKeyDown(event) {
if(!expanded) return
if (event.key === "Escape") {
closeImage();
} else if (event.key === "ArrowLeft") {
Expand All @@ -55,6 +57,8 @@
}
function handleTouchStart(event) {
if(!expanded) return
if (event.touches.length === 1) {
const t = event.touches[0];
touch.startX = t.clientX;
Expand All @@ -63,6 +67,8 @@
}
function handleTouchEnd(event) {
if(!expanded) return
if (event.changedTouches.length === 1) {
const t = event.changedTouches[0];
const deltaX = t.clientX - touch.startX;
Expand All @@ -81,13 +87,17 @@
}
function handleLeftArrow() {
if(!expanded) return
currentIndex = (currentIndex - 1 + images.length) % images.length;
flyX = -40
flyY = 0
show(currentIndex);
}
function handleRightArrow() {
if(!expanded) return
currentIndex = (currentIndex + 1) % images.length;
flyX = 40
flyY = 0
Expand All @@ -105,7 +115,7 @@
on:keydown>
{#if !loaded}
<div
class="fixed top-0 left-0 right-0 bottom-0 z-10 flex flex-col items-center justify-center text-white animate-pulse select-none"
class="fixed top-0 left-0 right-0 bottom-0 z-5 flex flex-col items-center justify-center text-white animate-pulse select-none"
transition:fade>
<img class="loading-image" alt="loading nahi" />
<span class="paragraph">Loading...</span>
Expand Down
1 change: 1 addition & 0 deletions src/lib/GallerySection.svelte
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<script>
import BackButton from "./BackButton.svelte";
import Gallery from "./Gallery.svelte";
import PricesSection from "./PricesSection.svelte";
import ToggleButton from "./ToggleButton.svelte";
export let images;
Expand Down

0 comments on commit 0b801f0

Please sign in to comment.