Skip to content

Make images smaller using best-in-class codecs, right in the browser.

JavaScript

Add fallback to window.onresize

Ewa Gasperowiczbcd88f6356e4
diff --git a/src/components/Output/custom-els/TwoUp/index.ts b/src/components/Output/custom-els/TwoUp/index.ts
index 034a6429..de03e7c8 100644
--- a/src/components/Output/custom-els/TwoUp/index.ts
+++ b/src/components/Output/custom-els/TwoUp/index.ts
@@ -38,8 +38,12 @@ export default class TwoUp extends HTMLElement {
.observe(this, { childList: true });
// Watch for element size changes.
- new ResizeObserver(() => this._resetPosition())
- .observe(this);
+ if (window.hasOwnProperty('ResizeObserver')) {
+ new ResizeObserver(() => this._resetPosition())
+ .observe(this);
+ } else {
+ window.addEventListener('resize', () => this._resetPosition());
+ }
// Watch for pointers on the handle.
const pointerTracker: PointerTracker = new PointerTracker(this._handle, {