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:
parent
bbef2a953e
commit
ab58b651f7
3 changed files with 69 additions and 4 deletions
|
|
@ -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;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue