yameta
This commit is contained in:
parent
51cf5c57f0
commit
9f79e494f5
|
@ -268,16 +268,12 @@ async function adjustScroll(fn: () => void): Promise<void> {
|
||||||
}
|
}
|
||||||
denyMoveTransition.value = true;
|
denyMoveTransition.value = true;
|
||||||
fn();
|
fn();
|
||||||
return await nextTick(() => {
|
return await nextTick().then(() => {
|
||||||
try {
|
const top = oldScroll + ((scrollableElement ? scrollableElement.scrollHeight : getBodyScrollHeight()) - oldHeight);
|
||||||
const top = oldScroll + ((scrollableElement ? scrollableElement.scrollHeight : getBodyScrollHeight()) - oldHeight);
|
scroll(scrollableElement, { top, behavior: 'instant' });
|
||||||
scroll(scrollableElement, { top, behavior: 'instant' });
|
// なぜかscrollableElementOrHtmlがundefinedであるというエラーが出る
|
||||||
// なぜかscrollableElementOrHtmlがundefinedであるというエラーが出る
|
scrollableElementOrHtml.removeEventListener('wheel', preventDefault);
|
||||||
scrollableElementOrHtml.removeEventListener('wheel', preventDefault);
|
scrollableElementOrHtml.removeEventListener('touchmove', preventDefault);
|
||||||
scrollableElementOrHtml.removeEventListener('touchmove', preventDefault);
|
|
||||||
} catch (err) {
|
|
||||||
console.error(err, { scrollableElementOrHtml });
|
|
||||||
}
|
|
||||||
}).then(() => nextTick()).finally(() => {
|
}).then(() => nextTick()).finally(() => {
|
||||||
denyMoveTransition.value = false;
|
denyMoveTransition.value = false;
|
||||||
});
|
});
|
||||||
|
@ -523,7 +519,7 @@ const prepend = (item: MisskeyEntity): void => {
|
||||||
*/
|
*/
|
||||||
function unshiftItems(newItems: MisskeyEntity[], limit = displayLimit.value) {
|
function unshiftItems(newItems: MisskeyEntity[], limit = displayLimit.value) {
|
||||||
const length = newItems.length + items.value.size;
|
const length = newItems.length + items.value.size;
|
||||||
items.value = new Map([...arrayToEntries(newItems), ...items.value].slice(0, limit));
|
items.value = new Map([...arrayToEntries(newItems), ...(newItems.length >= limit ? [] : items.value)].slice(0, limit));
|
||||||
|
|
||||||
if (length >= limit) more.value = true;
|
if (length >= limit) more.value = true;
|
||||||
}
|
}
|
||||||
|
@ -542,29 +538,26 @@ function concatItems(oldItems: MisskeyEntity[]) {
|
||||||
async function executeQueue() {
|
async function executeQueue() {
|
||||||
if (queue.value.size === 0) return;
|
if (queue.value.size === 0) return;
|
||||||
if (isPausingUpdateByExecutingQueue.value) return;
|
if (isPausingUpdateByExecutingQueue.value) return;
|
||||||
const queueArr = Array.from(queue.value.entries());
|
|
||||||
queue.value = new Map(queueArr.slice(props.pagination.limit));
|
|
||||||
const newItems = Array.from({ length: Math.min(queueArr.length, props.pagination.limit) }, (_, i) => queueArr[i][1]).reverse();
|
|
||||||
isPausingUpdateByExecutingQueue.value = true;
|
|
||||||
|
|
||||||
if (isWebKit) {
|
if (isWebKit) {
|
||||||
// Safariでは描画が微妙になるので一定程度スクロールするだけ
|
// Safariは最新のアイテムにするだけ
|
||||||
scrollBy(scrollableElement, { top: TOLERANCE + 4, behavior: 'instant' });
|
const newItems = Array.from(queue.value.values()).slice(-1 * props.pagination.limit);
|
||||||
backed = true;
|
unshiftItems(newItems);
|
||||||
denyMoveTransition.value = true;
|
queue.value = new Map();
|
||||||
await nextTick();
|
|
||||||
unshiftItems(newItems, Infinity);
|
|
||||||
await nextTick();
|
|
||||||
} else {
|
} else {
|
||||||
|
const queueArr = Array.from(queue.value.entries());
|
||||||
|
queue.value = new Map(queueArr.slice(props.pagination.limit));
|
||||||
|
const newItems = Array.from({ length: Math.min(queueArr.length, props.pagination.limit) }, (_, i) => queueArr[i][1]).reverse();
|
||||||
|
isPausingUpdateByExecutingQueue.value = true;
|
||||||
|
|
||||||
await adjustScroll(() => unshiftItems(newItems, Infinity));
|
await adjustScroll(() => unshiftItems(newItems, Infinity));
|
||||||
backed = true;
|
backed = true;
|
||||||
denyMoveTransition.value = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
items.value = new Map([...items.value].slice(0, displayLimit.value));
|
denyMoveTransition.value = true;
|
||||||
await nextTick();
|
items.value = new Map([...items.value].slice(0, displayLimit.value));
|
||||||
isPausingUpdateByExecutingQueue.value = false;
|
await nextTick();
|
||||||
denyMoveTransition.value = false;
|
isPausingUpdateByExecutingQueue.value = false;
|
||||||
|
denyMoveTransition.value = false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function prependQueue(newItem: MisskeyEntity) {
|
function prependQueue(newItem: MisskeyEntity) {
|
||||||
|
|
Loading…
Reference in New Issue