fix scroll position resetting on admin panel
All checks were successful
delpoy / build-and-deploy (push) Successful in 1m2s
All checks were successful
delpoy / build-and-deploy (push) Successful in 1m2s
This commit is contained in:
parent
5935b0d561
commit
8ea1750f1a
@ -6,6 +6,21 @@
|
|||||||
let bodyElem: HTMLTableSectionElement;
|
let bodyElem: HTMLTableSectionElement;
|
||||||
let intersectionElem: HTMLElement;
|
let intersectionElem: HTMLElement;
|
||||||
|
|
||||||
|
async function onUpdateProxy() {
|
||||||
|
let scrollElem: HTMLElement | null = bodyElem;
|
||||||
|
while (scrollElem && scrollElem.scrollHeight <= scrollElem.clientHeight) {
|
||||||
|
scrollElem = scrollElem.parentElement;
|
||||||
|
}
|
||||||
|
|
||||||
|
const scrollTop = scrollElem?.scrollTop ?? 0;
|
||||||
|
|
||||||
|
await onUpdate();
|
||||||
|
|
||||||
|
if (scrollElem) scrollElem.scrollTop = scrollTop;
|
||||||
|
|
||||||
|
await tick();
|
||||||
|
}
|
||||||
|
|
||||||
async function getIntersectionElement(): Promise<HTMLElement> {
|
async function getIntersectionElement(): Promise<HTMLElement> {
|
||||||
if (!bodyElem.lastElementChild) {
|
if (!bodyElem.lastElementChild) {
|
||||||
await new Promise<void>((resolve) => {
|
await new Promise<void>((resolve) => {
|
||||||
@ -21,8 +36,7 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
onMount(async () => {
|
onMount(async () => {
|
||||||
await onUpdate();
|
await onUpdateProxy();
|
||||||
await tick();
|
|
||||||
|
|
||||||
if (!bodyElem) return;
|
if (!bodyElem) return;
|
||||||
|
|
||||||
@ -33,8 +47,7 @@
|
|||||||
|
|
||||||
const rows = bodyElem.rows.length;
|
const rows = bodyElem.rows.length;
|
||||||
|
|
||||||
await onUpdate();
|
await onUpdateProxy();
|
||||||
await tick();
|
|
||||||
|
|
||||||
if (rows === bodyElem.rows.length) return;
|
if (rows === bodyElem.rows.length) return;
|
||||||
observer.observe((intersectionElem = await getIntersectionElement()));
|
observer.observe((intersectionElem = await getIntersectionElement()));
|
||||||
|
Loading…
x
Reference in New Issue
Block a user