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);