fix(frontend/scroll): no callback for disconnected elements (#11714)

* fix(frontend/scroll): no callback for disconnected elements

* Update CHANGELOG.md
This commit is contained in:
Kagami Sascha Rosylight
2023-08-13 14:22:57 +02:00
committed by GitHub
parent bbef2a953e
commit ab58b651f7
3 changed files with 69 additions and 4 deletions

View File

@@ -30,7 +30,7 @@ export function getScrollPosition(el: HTMLElement | null): number {
export function onScrollTop(el: HTMLElement, cb: () => unknown, tolerance = 1, once = false) {
// とりあえず評価してみる
if (isTopVisible(el)) {
if (el.isConnected && isTopVisible(el)) {
cb();
if (once) return null;
}
@@ -54,7 +54,7 @@ export function onScrollBottom(el: HTMLElement, cb: () => unknown, tolerance = 1
const container = getScrollContainer(el);
// とりあえず評価してみる
if (isBottomVisible(el, tolerance, container)) {
if (el.isConnected && isBottomVisible(el, tolerance, container)) {
cb();
if (once) return null;
}