web: 减少重绘

This commit is contained in:
Xwite 2023-05-11 14:41:29 +08:00
parent fc56d653b1
commit e12ad9ef4d

View File

@ -1,8 +1,5 @@
<template>
<div
:class="{ 'cata-wrapper': true, visible: popCataVisible }"
:style="popupTheme"
>
<div :class="{ 'cata-wrapper': true, correctSize }" :style="popupTheme">
<div class="title">目录</div>
<virtual-list
style="height: 300px; overflow: auto"
@ -77,9 +74,12 @@ const virtualListIndex = computed(() => {
return Math.floor(index.value / 2);
});
onUpdated(() => {
// domResizeObserversizes Map
virtualListRef.value.scrollToIndex(virtualListIndex.value);
const correctSize = ref(false);
watch(popCataVisible, (visible) => {
// virtualListsize0 ResizeObserver
if (visible && !correctSize.value) correctSize.value = true
if (!visible) return;
nextTick(() => virtualListRef.value.scrollToIndex(virtualListIndex.value));
});
</script>