Skip to content

Commit

Permalink
fix: instance properties and fix demo (#561)
Browse files Browse the repository at this point in the history
Co-authored-by: Alvaro Saburido <[email protected]>
  • Loading branch information
damienmontastier and alvarosabu authored Dec 16, 2024
1 parent 65a4ce9 commit f0fb337
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 8 deletions.
10 changes: 5 additions & 5 deletions docs/.vitepress/theme/components/PositionalAudioDemo.vue
Original file line number Diff line number Diff line change
Expand Up @@ -57,23 +57,23 @@ watch(helper.value, () => {
innerAngle.value.visible = outerAngle.value.visible = outerGain.value.visible = helper.value.value
})
watch([ballRef, ready], ([ball]) => {
if (!ball?.value || !ready.value) { return }
watch([ready], () => {
if (!ballRef?.value || !ready.value) { return }
ctx.add(() => {
tl = gsap
.timeline({ repeat: -1, yoyo: true, onRepeat: onBallBounce })
.to(ball.value.position, { y: 0, ease: 'power1.in', duration: 0.35 })
.to(ballRef.value.instance.position, { y: 0, ease: 'power1.in', duration: 0.35 })
})
})
onMounted(() => {
ctx = gsap.context((_) => { }, ballRef?.value)
ctx = gsap.context(() => { })
})
onUnmounted(() => {
ctx?.revert()
positionalAudioRef?.value?.dispose()
ctx?.revert()
})
</script>

Expand Down
4 changes: 2 additions & 2 deletions docs/guide/abstractions/positional-audio.md
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ If you are sure that there will be a user gesture before your `<PositionAudio>`

| Event | Description |
| :---------- | :--------------------------------------------------------------- |
| `root` | Root reference — Inheritance of [PositionalAudio](https://threejs.org/docs/index.html?q=posi#api/en/audio/PositionalAudio).|
| `instance` | Instance reference — Inheritance of [PositionalAudio](https://threejs.org/docs/index.html?q=posi#api/en/audio/PositionalAudio).|
| `play()` | Play audio — *Cannot be fired if audio is already running.* |
| `pause()` | Pause audio — *Cannot be fired if audio is already paused.* |
| `stop()` | Stop audio — *Cannot be fired if audio is already stopped.* |
Expand All @@ -76,7 +76,7 @@ If you are sure that there will be a user gesture before your `<PositionAudio>`
```typescript{1,3,8}
const positionalAudioRef = shallowRef(null)
console.log(positionalAudioRef.value.root) // root properties
console.log(positionalAudioRef.value.instance) // instance properties
const handlerAudio = (action: string) => {
if (!positionalAudioRef.value) return
Expand Down
2 changes: 1 addition & 1 deletion src/core/abstractions/PositionalAudio.vue
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ const dispose = () => {
}
defineExpose({
root: positionalAudioRef,
instance: positionalAudioRef,
play: playAudio,
stop: stopAudio,
pause: pauseAudio,
Expand Down

0 comments on commit f0fb337

Please sign in to comment.