Просмотр исходного кода

Revert "web: 减少重绘"

This reverts commit 2b1a7bf8d3cbf0ae16af1772e4a1fa26a9d915ca.
Xwite 3 лет назад
Родитель
Сommit
489ebae672
1 измененных файлов с 7 добавлено и 7 удалено
  1. 7 7
      modules/web/src/components/PopCatalog.vue

+ 7 - 7
modules/web/src/components/PopCatalog.vue

@@ -1,5 +1,8 @@
 <template>
-  <div :class="{ 'cata-wrapper': true, correctSize }" :style="popupTheme">
+  <div
+    :class="{ 'cata-wrapper': true, visible: popCataVisible }"
+    :style="popupTheme"
+  >
     <div class="title">目录</div>
     <virtual-list
       style="height: 300px; overflow: auto"
@@ -74,12 +77,9 @@ const virtualListIndex = computed(() => {
   return Math.floor(index.value / 2);
 });
 
-const correctSize = ref(false);
-watch(popCataVisible, (visible) => {
-  // 组件挂载时不可见 virtualList计算首屏的size为0 重新触发其内部的ResizeObserver
-  if (visible && !correctSize.value) correctSize.value = true
-  if (!visible) return;
-  nextTick(() => virtualListRef.value.scrollToIndex(virtualListIndex.value));
+onUpdated(() => {
+  // dom更新触发ResizeObserver,更新虚拟列表内部的sizes Map
+  virtualListRef.value.scrollToIndex(virtualListIndex.value);
 });
 </script>