From 5d55de844b30146b2267b46d516d9d81a9bd3854 Mon Sep 17 00:00:00 2001 From: Chris Amico Date: Tue, 5 Dec 2023 10:58:06 -0500 Subject: [PATCH] Catch more undefined things --- src/util/visibility.js | 3 +++ src/viewer/document.js | 3 ++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/src/util/visibility.js b/src/util/visibility.js index 58e5ff9d1..c3a19b0e8 100644 --- a/src/util/visibility.js +++ b/src/util/visibility.js @@ -1,6 +1,9 @@ // Adapted from https://svelte.dev/repl/ead0f1fcd2d4402bbbd64eca1d665341?version=3.14.1 export function showIfFullyVisible(el) { + // for very old browsers we don't support, bail + if (typeof window.IntersectionObserver === "undefined") return; + const setVisible = (visibility) => { el.style.visibility = visibility ? "visible" : "hidden"; }; diff --git a/src/viewer/document.js b/src/viewer/document.js index 2a4543cf9..b2a569966 100644 --- a/src/viewer/document.js +++ b/src/viewer/document.js @@ -227,7 +227,8 @@ class Doc extends Svue { if (this.scrollzoom == null) return resolve(); const scrollTop = - (this.scrollzoom.components[pageNumber].y - this.layout.pageGap / 4) * + (this.scrollzoom.components[pageNumber]?.y - + this.layout.pageGap / 4) * this.scrollzoom.transform.matrix[0]; if (this.scrollzoom.element != null) { this.scrollzoom.scrollTo(scrollTop);