// import { sequenceVideos } from "../data/sequenceVideos"; import { useState, useRef } from 'react'; import gsap from 'gsap'; import { useSwipeable } from 'react-swipeable'; import { motion, AnimatePresence } from 'motion/react'; import Button from './ui/Button'; import ArrowRightIcon from './icons/map/ArrowRightIcon'; import ArrowLeftIcon from './icons/ArrowLeftIcon'; import Compass from './Compass'; import { useNavigate } from 'react-router'; import InfoIcon from './icons/InfoIcon'; import FullScreenButton from './FullScreenButton'; import PrivacyPolicyButton from './PrivacyPolicyButton'; import DisclaimerButton from './DisclaimerButton'; import { masks } from '../data/masks'; interface SequenceSliderProps { complexName: string; } const FRAME_COUNT = 360; const FRAME_STEP = 90; function SequenceSlider({ complexName }: SequenceSliderProps) { const [currentIndex, setCurrentIndex] = useState(0); const [isAnimating, setIsAnimating] = useState(false); const handlers = useSwipeable({ onSwipedLeft: () => handleSwipe('next'), onSwipedRight: () => handleSwipe('prev'), preventScrollOnSwipe: true, touchEventOptions: { passive: false, }, trackMouse: true, }); const [imageLoaded, setImageLoaded] = useState(0); const [isShowVideo, setIsShowVideo] = useState(true); const directionRef = useRef<'next' | 'prev'>('next'); const [isFullScreen, setIsFullScreen] = useState(false); function handleImageLoad() { setImageLoaded((prev) => prev + 1); } function handleSwipe(direction: 'next' | 'prev') { if (imageLoaded < FRAME_COUNT) return; directionRef.current = direction; setIsShowVideo(false); } function handleLoadVideo() {} function animate(direction: 'next' | 'prev') { setIsAnimating(true); const targetIndex = currentIndex + (direction === 'next' ? FRAME_STEP : -FRAME_STEP); // -1, -2 gsap.to( { value: currentIndex }, { value: targetIndex, duration: 1, ease: 'power2.inOut', onUpdate: function () { const currentValue = Math.round(this.targets()[0].value); if (currentValue > FRAME_COUNT - 1 || currentValue < 0) { setCurrentIndex(FRAME_COUNT - Math.abs(currentValue)); } else { setCurrentIndex(currentValue); } }, onComplete: () => { setIsAnimating(false); setIsShowVideo(true); }, } ); } function handleFullScreenClick() { if (!rootRef.current) return; setIsFullScreen((prev) => !prev); if (isFullScreen) { document.exitFullscreen(); } else { rootRef.current.requestFullscreen(); } } const rootRef = useRef(null); const navigate = useNavigate(); return (
{ handlers.ref(el); rootRef.current = el; }} className='relative h-full overflow-hidden' > {imageLoaded < FRAME_COUNT && (

{Math.round((imageLoaded / FRAME_COUNT) * 100)}%

)}
{Array.from({ length: FRAME_COUNT }).map((_, index) => ( ))} {isShowVideo && ( { if (!opacity) { animate(directionRef.current); } }} /> )} {!isAnimating && ( navigate('floors')} /> )} {imageLoaded === FRAME_COUNT && ( <>

ROVE Home Marasi Drive

)}
); } export default SequenceSlider;