fix: Prevent gallery auto-scrolling from scrolling entire browser (#1824)
- Closes #1814
This commit is contained in:
@@ -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;
|
||||
});
|
||||
};
|
||||
Reference in New Issue
Block a user