Skip to content

Commit

Permalink
fix: remove fading
Browse files Browse the repository at this point in the history
  • Loading branch information
remvze committed Jan 29, 2024
1 parent 5467bbb commit d96461d
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 23 deletions.
4 changes: 2 additions & 2 deletions src/components/sound/sound.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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]);

Expand Down
23 changes: 2 additions & 21 deletions src/hooks/use-sound.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit d96461d

Please sign in to comment.