fix: Prevent gallery auto-scrolling from scrolling entire browser (#1824)

- Closes #1814
This commit is contained in:
Dermot Duffy
2025-01-11 16:44:05 -08:00
committed by GitHub
parent addf6edb30
commit 1f37895793
6 changed files with 60 additions and 2 deletions
+13
View File
@@ -0,0 +1,13 @@
import { compute as computeScroll, Options } from 'compute-scroll-into-view';
// Alternative to the stock element.scrollIntoView that suppports limiting
// scrolling to a boundary, rather than the entire browser root.
//
// See: https://github.com/dermotduffy/frigate-hass-card/issues/1814
// See: https://github.com/w3c/csswg-drafts/issues/9452
export const scrollIntoView = (element: HTMLElement, options: Options) => {
computeScroll(element, options).forEach(({ el, top, left }) => {
el.scrollTop = top;
el.scrollLeft = left;
});
};