From d96461d1ea83c72bfe651d84cf34fabc029c200e Mon Sep 17 00:00:00 2001 From: MAZE Date: Mon, 29 Jan 2024 19:16:46 +0330 Subject: [PATCH] fix: remove fading --- src/components/sound/sound.tsx | 4 ++-- src/hooks/use-sound.ts | 23 ++--------------------- 2 files changed, 4 insertions(+), 23 deletions(-) diff --git a/src/components/sound/sound.tsx b/src/components/sound/sound.tsx index eb599b8..c6fc1eb 100644 --- a/src/components/sound/sound.tsx +++ b/src/components/sound/sound.tsx @@ -43,9 +43,9 @@ export function Sound({ useEffect(() => { if (isSelected && isPlaying && functional) { - sound?.fadeIn(); + sound?.play(); } else { - sound?.fadeOut(); + sound?.pause(); } }, [isSelected, sound, isPlaying, functional]); diff --git a/src/hooks/use-sound.ts b/src/hooks/use-sound.ts index ff9e881..eb1e501 100644 --- a/src/hooks/use-sound.ts +++ b/src/hooks/use-sound.ts @@ -62,28 +62,9 @@ export function useSound( if (sound) sound.pause(); }, [sound]); - const fadeIn = useCallback(() => { - if (sound) { - if (!sound.playing()) { - play(); - sound.fade(0, options.volume || 0.5, 1000); - } - } - }, [play, sound, options.volume]); - - const fadeOut = useCallback(() => { - if (sound) { - sound.fade(options.volume || 0.5, 0, 1000); - - setTimeout(() => { - sound.pause(); - }, 1200); - } - }, [sound, options.volume]); - const control = useMemo( - () => ({ fadeIn, fadeOut, isLoading, pause, play, stop }), - [play, stop, pause, isLoading, fadeIn, fadeOut], + () => ({ isLoading, pause, play, stop }), + [play, stop, pause, isLoading], ); return control;