'use client'; import React, { useState, useEffect } from 'react'; import { motion, useAnimation } from 'framer-motion'; import { useInView } from 'react-intersection-observer'; import { debounce } from 'lodash'; const FilmRoll = ({ videos }: { videos: string[] }) => { const controls = useAnimation(); useEffect(() => { const updateAnimationSpeed = debounce(() => { const isMobile = window.innerWidth < 640; const duration = isMobile ? 10 : 40; controls.start({ x: ['0%', '-100%'], transition: { duration, ease: 'linear', repeat: Infinity, repeatType: 'loop', }, }); }, 100); updateAnimationSpeed(); window.addEventListener('resize', updateAnimationSpeed); return () => window.removeEventListener('resize', updateAnimationSpeed); }, [controls]); return (
{[...Array(2)].map((_, containerIndex) => (
{videos.map((videoUrl, index) => ( ))}
))}
); }; const ZoomableVideo = ({ videoUrl }: { videoUrl: string }) => { const [hovered, setHovered] = useState(false); const [position, setPosition] = useState({ x: 0, y: 0 }); const { ref, inView } = useInView({ triggerOnce: true, threshold: 0.1 }); const handleMouseMove = (e: React.MouseEvent) => { const { left, top } = e.currentTarget.getBoundingClientRect(); const x = e.clientX - left; const y = e.clientY - top; setPosition({ x, y }); }; return (
setHovered(true)} onMouseLeave={() => setHovered(false)} onMouseMove={handleMouseMove} style={{ transition: 'transform 0.5s cubic-bezier(0.25, 0.8, 0.25, 1)' }} > {inView && ( Your browser does not support the video tag. )} {hovered && (
)}
); }; const FilmPerforations: React.FC = React.memo(function FilmPerforations() { return (
{[...Array(20)].map((_, index) => (
))}
); }); export default FilmRoll;