From 8307657628c0afc7ef11c3a829344a64777dc1d3 Mon Sep 17 00:00:00 2001 From: MAZE Date: Fri, 26 Apr 2024 12:40:04 +0330 Subject: [PATCH] fix: replace the animation on button --- src/components/sounds/sounds.tsx | 57 +++++++++++++++----------------- 1 file changed, 27 insertions(+), 30 deletions(-) diff --git a/src/components/sounds/sounds.tsx b/src/components/sounds/sounds.tsx index 8e99751..6fc1a2c 100644 --- a/src/components/sounds/sounds.tsx +++ b/src/components/sounds/sounds.tsx @@ -20,6 +20,8 @@ export function Sounds({ functional, id, sounds }: SoundsProps) { const [showAll, setShowAll] = useLocalStorage(`${id}-show-more`, false); const [clickedMore, setClickedMore] = useState(false); + const [isAnimating, setIsAnimating] = useState(false); + const firstNewSound = useRef(null); useEffect(() => { @@ -30,7 +32,6 @@ export function Sounds({ functional, id, sounds }: SoundsProps) { }, [showAll, clickedMore]); const showMoreButton = useRef(null); - const [exitComplete, setExitComplete] = useState(false); const [hiddenSelections, setHiddenSelections] = useState<{ [key: string]: boolean; @@ -57,8 +58,10 @@ export function Sounds({ functional, id, sounds }: SoundsProps) { }, []); const toggleMore = () => { - setShowAll(prev => !prev); - setClickedMore(true); + if (!isAnimating) { + setShowAll(prev => !prev); + setClickedMore(true); + } }; const variants = mix(fade(), scale(0.9)); @@ -85,34 +88,28 @@ export function Sounds({ functional, id, sounds }: SoundsProps) { {sounds.length > 6 && ( - setExitComplete(true)} + )} );