From 535801dcf5e885e462efd0693269ae177bcd4684 Mon Sep 17 00:00:00 2001 From: Jaime A Torrealba C Date: Thu, 5 Oct 2023 15:07:20 -0300 Subject: [PATCH] chore: reviews changes --- docs/guide/abstractions/global-audio.md | 20 +++++++++---------- .../pages/abstractions/GlobalAudioDemo.vue | 4 ++-- src/core/abstractions/GlobalAudio.ts | 12 +++++------ 3 files changed, 18 insertions(+), 18 deletions(-) diff --git a/docs/guide/abstractions/global-audio.md b/docs/guide/abstractions/global-audio.md index 93e565dc..da107b7f 100644 --- a/docs/guide/abstractions/global-audio.md +++ b/docs/guide/abstractions/global-audio.md @@ -22,18 +22,18 @@ import { GlobalAudio } from '@tresjs/cientos' ## Props -| Prop | Description | Default | -| :------------- | :------------------------------------------------- | --------------------- | -| `src` | Path to your audio file | | -| `playElement` | Id of the DOM element that trigger the play state | `renderer.domElement` | -| `pauseElement` | Id of the DOM element that trigger the pause state | | -| `stopElement` | Id of the DOM element that trigger the stop state | | -| `loop` | If the audio must be replayed when ends | `false` | -| `volume` | Volume of the audio. | `0.5` | -| `playbackRate` | PlaybackRate of the audio | `1` | +| Prop | Description | Default | +| :------------- | :-------------------------------------------------- | --------------------- | +| `src` | Path to your audio file | | +| `playElement` | Id of the DOM element that triggers the play state | `renderer.domElement` | +| `pauseElement` | Id of the DOM element that triggers the pause state | | +| `stopElement` | Id of the DOM element that triggers the stop state | | +| `loop` | If the audio must be replayed when ends | `false` | +| `volume` | Volume of the audio | `0.5` | +| `playbackRate` | PlaybackRate of the audio | `1` | ## Events | Event | Description | | :---------- | :---------------------------------------------------------------- | -| `isPlaying` | Dispatched when the Audio change its state (play, pause or stop). | +| `isPlaying` | Dispatched when the Audio change its state (play, pause or stop) | diff --git a/playground/src/pages/abstractions/GlobalAudioDemo.vue b/playground/src/pages/abstractions/GlobalAudioDemo.vue index 20953d80..961c0f8d 100644 --- a/playground/src/pages/abstractions/GlobalAudioDemo.vue +++ b/playground/src/pages/abstractions/GlobalAudioDemo.vue @@ -39,9 +39,9 @@ const options = useControls({ /> ({ } }) - watch(() => [props.playbackRate], () => sound.setPlaybackRate( props.playbackRate || 1 ), { immediate: true }) - watch(() => [props.volume], () => sound.setVolume( props.volume || 0.5 ), { immediate: true }) - watch(() => [props.loop], () => sound.setLoop( props.loop || false ), { immediate: true }) + watch(() => [props.playbackRate], () => sound.setPlaybackRate( props.playbackRate ?? 1 ), { immediate: true }) + watch(() => [props.volume], () => sound.setVolume( props.volume ?? 0.5 ), { immediate: true }) + watch(() => [props.loop], () => sound.setLoop( props.loop ?? false ), { immediate: true }) watch(() => [props.src], async () => { const buffer = await audioLoader.loadAsync( props.src) sound.setBuffer( buffer ) }, { immediate: true }) - const selector = document.getElementById(props.playElement || '') + const selector = document.getElementById(props.playElement ?? '') const btnPlay = selector ? selector : renderer.value.domElement useEventListener(btnPlay, 'click', () => { sound.play() emit('isPlaying', sound.isPlaying) }) - const btnPause = document.getElementById(props.pauseElement || '') + const btnPause = document.getElementById(props.pauseElement ?? '') if (btnPause) { useEventListener(btnPause, 'click', () => { sound.pause() @@ -116,7 +116,7 @@ export const GlobalAudio = defineComponent({ }) } - const btnStop = document.getElementById(props.stopElement || '') + const btnStop = document.getElementById(props.stopElement ?? '') if (btnStop) { useEventListener(btnStop, 'click', () => { sound.stop()