bug: stop scrolling page when moving through search results
[apps/outliner/.git] / src / dom.ts
diff --git a/src/dom.ts b/src/dom.ts
new file mode 100644 (file)
index 0000000..481c5ed
--- /dev/null
@@ -0,0 +1,9 @@
+export function isVisible(element: HTMLElement): boolean {
+    const rect = element.getBoundingClientRect();
+    return (
+        rect.top >= 0 &&
+        rect.left >= 0 &&
+        rect.bottom <= (window.innerHeight || document.documentElement.clientHeight) &&     
+        rect.right <= (window.innerWidth || document.documentElement.clientWidth)
+    );
+}