Skip to content

Commit

Permalink
Fix: check if ResizeObserver is defined (Safari 12)
Browse files Browse the repository at this point in the history
  • Loading branch information
katspaugh committed Jun 9, 2024
1 parent 764c9eb commit 8982055
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions src/renderer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -109,13 +109,15 @@ class Renderer extends EventEmitter<RendererEvents> {
})

// Re-render the waveform on container resize
const delay = this.createDelay(100)
this.resizeObserver = new ResizeObserver(() => {
delay()
.then(() => this.onContainerResize())
.catch(() => undefined)
})
this.resizeObserver.observe(this.scrollContainer)
if (typeof ResizeObserver === 'function') {
const delay = this.createDelay(100)
this.resizeObserver = new ResizeObserver(() => {
delay()
.then(() => this.onContainerResize())
.catch(() => undefined)
})
this.resizeObserver.observe(this.scrollContainer)
}
}

private onContainerResize() {
Expand Down

0 comments on commit 8982055

Please sign in to comment.