revert...
This commit is contained in:
parent
5a5ef7564a
commit
41824ae383
1 changed files with 23 additions and 2 deletions
|
@ -233,6 +233,10 @@ watch([$$(weakBacked), $$(contentEl)], () => {
|
||||||
})();
|
})();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
function preventDefault(ev: Event) {
|
||||||
|
ev.preventDefault();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* アイテムを上に追加した場合に追加分だけスクロールを下にずらす
|
* アイテムを上に追加した場合に追加分だけスクロールを下にずらす
|
||||||
* @param fn DOM操作(unshiftItemsなどで)
|
* @param fn DOM操作(unshiftItemsなどで)
|
||||||
|
@ -240,15 +244,32 @@ watch([$$(weakBacked), $$(contentEl)], () => {
|
||||||
function adjustScroll(fn: () => void): Promise<void> {
|
function adjustScroll(fn: () => void): Promise<void> {
|
||||||
const oldHeight = scrollableElement ? scrollableElement.scrollHeight : getBodyScrollHeight();
|
const oldHeight = scrollableElement ? scrollableElement.scrollHeight : getBodyScrollHeight();
|
||||||
const oldScroll = scrollableElement ? scrollableElement.scrollTop : window.scrollY;
|
const oldScroll = scrollableElement ? scrollableElement.scrollTop : window.scrollY;
|
||||||
|
// スクロールをやめさせる
|
||||||
|
try {
|
||||||
|
// なぜかscrollableElementOrHtmlがundefinedであるというエラーが出る
|
||||||
|
scrollableElementOrHtml.addEventListener('wheel', preventDefault, { passive: false });
|
||||||
|
scrollableElementOrHtml.addEventListener('touchmove', preventDefault, { passive: false });
|
||||||
|
// ついでにtryに入れてみる
|
||||||
|
scroll(scrollableElement, { top: oldScroll, behavior: 'instant' });
|
||||||
|
} catch (err) {
|
||||||
|
console.error(err, { scrollableElementOrHtml });
|
||||||
|
}
|
||||||
|
|
||||||
denyMoveTransition.value = true;
|
denyMoveTransition.value = true;
|
||||||
|
|
||||||
fn();
|
fn();
|
||||||
|
|
||||||
return nextTick(() => {
|
return nextTick(() => {
|
||||||
const top = oldScroll + ((scrollableElement ? scrollableElement.scrollHeight : getBodyScrollHeight()) - oldHeight);
|
try {
|
||||||
scroll(scrollableElement, { top, behavior: 'instant' });
|
const top = oldScroll + ((scrollableElement ? scrollableElement.scrollHeight : getBodyScrollHeight()) - oldHeight);
|
||||||
|
scroll(scrollableElement, { top, behavior: 'instant' });
|
||||||
|
|
||||||
|
// なぜかscrollableElementOrHtmlがundefinedであるというエラーが出る
|
||||||
|
scrollableElementOrHtml.removeEventListener('wheel', preventDefault);
|
||||||
|
scrollableElementOrHtml.removeEventListener('touchmove', preventDefault);
|
||||||
|
} catch (err) {
|
||||||
|
console.error(err, { scrollableElementOrHtml });
|
||||||
|
}
|
||||||
denyMoveTransition.value = false;
|
denyMoveTransition.value = false;
|
||||||
return nextTick();
|
return nextTick();
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in a new issue