From 0079f3394bdb4093e7e58426dcc3505abe8e653d Mon Sep 17 00:00:00 2001 From: tamaina Date: Tue, 18 Jul 2023 03:33:38 +0000 Subject: [PATCH] nextTick? --- packages/frontend/src/components/MkPagination.vue | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/packages/frontend/src/components/MkPagination.vue b/packages/frontend/src/components/MkPagination.vue index f2defe25e2..6d7786a9d3 100644 --- a/packages/frontend/src/components/MkPagination.vue +++ b/packages/frontend/src/components/MkPagination.vue @@ -251,7 +251,11 @@ function preventDefault(ev: Event) { * ChromeやFirefoxはこれをいい感じにやってくれるが、Safariはやってくれないため自分で実装する必要がある * @param fn DOM操作(unshiftItemsなどで) */ -function adjustScroll(fn: () => void): Promise { +async function adjustScroll(fn: () => void): Promise { + denyMoveTransition.value = true; + + await nextTick(); + const oldHeight = scrollableElement ? scrollableElement.scrollHeight : getBodyScrollHeight(); const oldScroll = scrollableElement ? scrollableElement.scrollTop : window.scrollY; // スクロールをやめさせる @@ -265,11 +269,9 @@ function adjustScroll(fn: () => void): Promise { console.error(err, { scrollableElementOrHtml }); } - denyMoveTransition.value = true; - fn(); - return nextTick(() => { + return await nextTick(() => { try { // scrollByで移動すればいいように思うがうまくいかない、なぜ?? const top = oldScroll + ((scrollableElement ? scrollableElement.scrollHeight : getBodyScrollHeight()) - oldHeight);