diff --git a/src/components/Devices.tsx b/src/components/Devices.tsx index c4edf9b..9ffefab 100644 --- a/src/components/Devices.tsx +++ b/src/components/Devices.tsx @@ -54,7 +54,7 @@ function DesktopDevice({ className="py-10 border-b border-[#3D425C] flex justify-between items-start relative [clip-path:polygon(0%_-50%,100%_-50%,100%_100%,-50%_100%)]" animate={{ height: hovered - ? +(root.current?.clientHeight ?? 0) + descriptionHeight + 24 + ? (root.current?.clientHeight ?? 0) + descriptionHeight + 24 : 112, }} > diff --git a/src/components/ui/SliderControls.tsx b/src/components/ui/SliderControls.tsx index 08afed3..c773097 100644 --- a/src/components/ui/SliderControls.tsx +++ b/src/components/ui/SliderControls.tsx @@ -1,6 +1,7 @@ -import { forwardRef, useEffect, useImperativeHandle, useRef } from 'react'; +import { forwardRef, useImperativeHandle, useRef } from 'react'; import { ArrowLeftIcon } from '../icons/ArrowLeftIcon'; import { ArrowRightIcon } from '../icons/ArrowRightIcon'; +import { delay } from 'framer-motion'; export const SliderControls = forwardRef< { left: () => void; right: () => void }, @@ -32,34 +33,11 @@ export const SliderControls = forwardRef< const nextBtnRef = useRef(null); const rectRef = useRef(null); - useEffect(() => { - const interval = setInterval(() => { - nextBtnRef.current?.click(); - }, 1000); - - return () => clearInterval(interval); - }, [onRightClick]); - useImperativeHandle(ref, () => ({ left: () => prevBtnRef.current?.click(), right: () => nextBtnRef.current?.click(), })); - // useEffect(() => { - // if (slide + 1 === slidesCount) { - // rectRef.current!.classList.remove('transition-all', 'duration-300'); - // rectRef.current!.setAttribute('stroke-dasharray', `0 ${length}`); - // } - - // return () => { - // rectRef.current!.classList.add('transition-all', 'duration-300'); - // }; - // }, [length, slide, slidesCount]); - - // useEffect(() => { - // rectRef.current!.classList.add('transition-all', 'duration-300'); - // }, []); - return (
@@ -102,26 +80,19 @@ export const SliderControls = forwardRef< ref={prevBtnRef} onClick={() => { if (slide === 0) { - let timeout: number | undefined; rectRef.current!.classList.remove( 'transition-all', 'duration-300', ); rectRef.current!.setAttribute('stroke-dasharray', `${length} 0`); - new Promise( - res => - (timeout = setTimeout(() => { - rectRef.current!.classList.add( - 'transition-all', - 'duration-300', - ); - res(); - }, 1)), - ).then(() => { - onLeftClick(); - clearTimeout(timeout); - }); - } else onLeftClick(); + delay(() => { + rectRef.current!.classList.add( + 'transition-all', + 'duration-300', + ); + }, 1); + } + onLeftClick(); }} className="rounded-full sm:p-5 p-4 border border-[#3D425C] bg-[#14161F]" > @@ -130,25 +101,19 @@ export const SliderControls = forwardRef<