nextTick?

This commit is contained in:
tamaina 2023-07-18 03:33:38 +00:00
parent cb63a1ed00
commit 0079f3394b

View file

@ -251,7 +251,11 @@ function preventDefault(ev: Event) {
* ChromeやFirefoxはこれをいい感じにやってくれるがSafariはやってくれないため自分で実装する必要がある
* @param fn DOM操作(unshiftItemsなどで)
*/
function adjustScroll(fn: () => void): Promise<void> {
async function adjustScroll(fn: () => void): Promise<void> {
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<void> {
console.error(err, { scrollableElementOrHtml });
}
denyMoveTransition.value = true;
fn();
return nextTick(() => {
return await nextTick(() => {
try {
// scrollBy
const top = oldScroll + ((scrollableElement ? scrollableElement.scrollHeight : getBodyScrollHeight()) - oldHeight);