diff --git a/app/globals.css b/app/globals.css index d7b5369aa..0978d5dd9 100644 --- a/app/globals.css +++ b/app/globals.css @@ -123,6 +123,7 @@ --booking-widget-z-index: 10; --booking-widget-open-z-index: 100; --dialog-z-index: 9; + --back-to-top-button: 80; --sidepeek-z-index: 100; --lightbox-z-index: 150; --default-modal-overlay-z-index: 100; diff --git a/components/Lightbox/FullView.tsx b/components/Lightbox/FullView.tsx index 73308f2c2..fa880ad4e 100644 --- a/components/Lightbox/FullView.tsx +++ b/components/Lightbox/FullView.tsx @@ -1,5 +1,6 @@ "use client" import { AnimatePresence, motion } from "framer-motion" +import { useState } from "react" import ArrowRightIcon from "@/components/Icons/ArrowRight" import CloseIcon from "@/components/Icons/Close" @@ -20,10 +21,35 @@ export default function FullView({ currentIndex, totalImages, }: FullViewProps) { + const [animateLeft, setAnimateLeft] = useState(true) + function handleSwipe(offset: number) { if (offset > 30) onPrev() if (offset < -30) onNext() } + + function handleNext() { + setAnimateLeft(true) + onNext() + } + + function handlePrev() { + setAnimateLeft(false) + onPrev() + } + + const variants = { + initial: (animateLeft: boolean) => ({ + opacity: 0, + x: animateLeft ? 300 : -300, + }), + animate: { opacity: 1, x: 0 }, + exit: (animateLeft: boolean) => ({ + opacity: 0, + x: animateLeft ? -300 : 300, + }), + } + return (
- + diff --git a/components/Lightbox/Gallery.tsx b/components/Lightbox/Gallery.tsx index eca08bd22..686191edf 100644 --- a/components/Lightbox/Gallery.tsx +++ b/components/Lightbox/Gallery.tsx @@ -1,5 +1,6 @@ "use client" import { AnimatePresence, motion } from "framer-motion" +import { useState } from "react" import { useIntl } from "react-intl" import { ChevronLeftIcon } from "@/components/Icons" @@ -21,12 +22,13 @@ export default function Gallery({ selectedImage, }: GalleryProps) { const intl = useIntl() + const [animateLeft, setAnimateLeft] = useState(true) const mainImage = selectedImage || images[0] const mainImageIndex = images.findIndex((img) => img === mainImage) function getThumbImages() { const thumbs = [] - for (let i = 1; i <= 5; i++) { + for (let i = 1; i <= Math.min(5, images.length); i++) { const index = (mainImageIndex + i) % images.length thumbs.push(images[index]) } @@ -34,15 +36,29 @@ export default function Gallery({ } function handleNext() { + setAnimateLeft(true) const nextIndex = (mainImageIndex + 1) % images.length onSelectImage(images[nextIndex]) } function handlePrev() { + setAnimateLeft(false) const prevIndex = (mainImageIndex - 1 + images.length) % images.length onSelectImage(images[prevIndex]) } + const variants = { + initial: (animateLeft: boolean) => ({ + opacity: 0, + x: animateLeft ? 300 : -300, + }), + animate: { opacity: 1, x: 0 }, + exit: (animateLeft: boolean) => ({ + opacity: 0, + x: animateLeft ? -300 : 300, + }), + } + return (