mirror of
https://github.com/gedoor/legado.git
synced 2024-09-01 09:34:25 +08:00
web: 减少重绘
This commit is contained in:
parent
fc56d653b1
commit
e12ad9ef4d
@ -1,8 +1,5 @@
|
|||||||
<template>
|
<template>
|
||||||
<div
|
<div :class="{ 'cata-wrapper': true, correctSize }" :style="popupTheme">
|
||||||
:class="{ 'cata-wrapper': true, visible: popCataVisible }"
|
|
||||||
:style="popupTheme"
|
|
||||||
>
|
|
||||||
<div class="title">目录</div>
|
<div class="title">目录</div>
|
||||||
<virtual-list
|
<virtual-list
|
||||||
style="height: 300px; overflow: auto"
|
style="height: 300px; overflow: auto"
|
||||||
@ -77,9 +74,12 @@ const virtualListIndex = computed(() => {
|
|||||||
return Math.floor(index.value / 2);
|
return Math.floor(index.value / 2);
|
||||||
});
|
});
|
||||||
|
|
||||||
onUpdated(() => {
|
const correctSize = ref(false);
|
||||||
// dom更新触发ResizeObserver,更新虚拟列表内部的sizes Map
|
watch(popCataVisible, (visible) => {
|
||||||
virtualListRef.value.scrollToIndex(virtualListIndex.value);
|
// 组件挂载时不可见 virtualList计算首屏的size为0 重新触发其内部的ResizeObserver
|
||||||
|
if (visible && !correctSize.value) correctSize.value = true
|
||||||
|
if (!visible) return;
|
||||||
|
nextTick(() => virtualListRef.value.scrollToIndex(virtualListIndex.value));
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user