From 8982055b3f8acb9ac059f775395e5eeaecec6299 Mon Sep 17 00:00:00 2001 From: katspaugh Date: Sun, 9 Jun 2024 10:05:17 +0200 Subject: [PATCH] Fix: check if ResizeObserver is defined (Safari 12) --- src/renderer.ts | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/src/renderer.ts b/src/renderer.ts index 04bfaf9b0..bab500cb9 100644 --- a/src/renderer.ts +++ b/src/renderer.ts @@ -109,13 +109,15 @@ class Renderer extends EventEmitter { }) // 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() {