import { AnimatePresence, motion, useAnimation } from 'framer-motion'; import { useRef } from 'react'; import { indexElements } from '@/lib/index/data'; import IphoneFrame from '../IphoneFrame'; function IndexIphoneFrame({ selected, setSelected, selectedComponent, selectedStyle, }) { const controls = useAnimation(); const constraintsRef = useRef(null); const onDrag = (e, info) => { controls.set({ y: info.offset.y }); }; function onDragEnd(event, info) { const { velocity, point } = info; const shouldClose = velocity.y > 20 || (velocity.y >= 0 && point.y > 45); if (shouldClose) { controls.start('hidden'); } else { controls.start('visible'); } } const selectionBody = indexElements.map((item) => ( )); return (
{selected}
{selectedComponent(selected)}
controls.start('hidden')} transition={{ delay: 0, }} variants={{ visible: { opacity: 1, pointerEvents: 'auto' }, hidden: { opacity: 0, pointerEvents: 'none' }, }} />
controls.start('visible')} />
{selectionBody}
); } export default IndexIphoneFrame;