@v-c/virtual-list 1.0.1 → 1.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/List.cjs CHANGED
@@ -2,7 +2,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
2
2
  const require_rolldown_runtime = require("./_virtual/rolldown_runtime.cjs");
3
3
  const require_Filler = require("./Filler.cjs");
4
4
  const require_Item = require("./Item.cjs");
5
- const require_useDiffItem = require("./hooks/useDiffItem.cjs");
6
5
  const require_useFrameWheel = require("./hooks/useFrameWheel.cjs");
7
6
  const require_useGetSize = require("./hooks/useGetSize.cjs");
8
7
  const require_useHeights = require("./hooks/useHeights.cjs");
@@ -77,7 +76,10 @@ var List_default = /* @__PURE__ */ (0, vue.defineComponent)({
77
76
  return item?.[_itemKey];
78
77
  };
79
78
  const [setInstanceRef, collectHeight, heights, heightUpdatedMark] = require_useHeights.default(getKey, void 0, void 0);
80
- const mergedData = (0, vue.computed)(() => props.data || EMPTY_DATA);
79
+ const mergedData = (0, vue.shallowRef)(props?.data || EMPTY_DATA);
80
+ (0, vue.watch)(() => props.data, () => {
81
+ mergedData.value = props?.data || EMPTY_DATA;
82
+ });
81
83
  const useVirtual = (0, vue.computed)(() => !!(props.virtual !== false && props.height && props.itemHeight));
82
84
  const containerHeight = (0, vue.computed)(() => Object.values(heights.maps).reduce((total, curr) => total + curr, 0));
83
85
  const inVirtual = (0, vue.computed)(() => {
@@ -108,7 +110,6 @@ var List_default = /* @__PURE__ */ (0, vue.defineComponent)({
108
110
  if (componentRef.value) componentRef.value.scrollTop = alignedTop;
109
111
  offsetTop.value = alignedTop;
110
112
  }
111
- require_useDiffItem.default(mergedData, getKey);
112
113
  (0, vue.watch)([
113
114
  inVirtual,
114
115
  useVirtual,
@@ -149,6 +150,10 @@ var List_default = /* @__PURE__ */ (0, vue.defineComponent)({
149
150
  }
150
151
  if (currentItemBottom > offsetTop.value + height && endIndex === void 0) endIndex = i;
151
152
  itemTop = currentItemBottom;
153
+ if (startIndex !== void 0 && endIndex !== void 0) {
154
+ itemTop = currentItemBottom + (dataLen - 1 - i) * itemHeight$1;
155
+ break;
156
+ }
152
157
  }
153
158
  if (startIndex === void 0) {
154
159
  startIndex = 0;
package/dist/List.js CHANGED
@@ -1,6 +1,5 @@
1
1
  import Filler_default from "./Filler.js";
2
2
  import Item_default from "./Item.js";
3
- import useDiffItem from "./hooks/useDiffItem.js";
4
3
  import useFrameWheel from "./hooks/useFrameWheel.js";
5
4
  import { useGetSize } from "./hooks/useGetSize.js";
6
5
  import useHeights from "./hooks/useHeights.js";
@@ -74,7 +73,10 @@ var List_default = /* @__PURE__ */ defineComponent({
74
73
  return item?.[_itemKey];
75
74
  };
76
75
  const [setInstanceRef, collectHeight, heights, heightUpdatedMark] = useHeights(getKey, void 0, void 0);
77
- const mergedData = computed(() => props.data || EMPTY_DATA);
76
+ const mergedData = shallowRef(props?.data || EMPTY_DATA);
77
+ watch(() => props.data, () => {
78
+ mergedData.value = props?.data || EMPTY_DATA;
79
+ });
78
80
  const useVirtual = computed(() => !!(props.virtual !== false && props.height && props.itemHeight));
79
81
  const containerHeight = computed(() => Object.values(heights.maps).reduce((total, curr) => total + curr, 0));
80
82
  const inVirtual = computed(() => {
@@ -105,7 +107,6 @@ var List_default = /* @__PURE__ */ defineComponent({
105
107
  if (componentRef.value) componentRef.value.scrollTop = alignedTop;
106
108
  offsetTop.value = alignedTop;
107
109
  }
108
- useDiffItem(mergedData, getKey);
109
110
  watch([
110
111
  inVirtual,
111
112
  useVirtual,
@@ -146,6 +147,10 @@ var List_default = /* @__PURE__ */ defineComponent({
146
147
  }
147
148
  if (currentItemBottom > offsetTop.value + height && endIndex === void 0) endIndex = i;
148
149
  itemTop = currentItemBottom;
150
+ if (startIndex !== void 0 && endIndex !== void 0) {
151
+ itemTop = currentItemBottom + (dataLen - 1 - i) * itemHeight$1;
152
+ break;
153
+ }
149
154
  }
150
155
  if (startIndex === void 0) {
151
156
  startIndex = 0;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@v-c/virtual-list",
3
3
  "type": "module",
4
- "version": "1.0.1",
4
+ "version": "1.0.2",
5
5
  "description": "Vue Virtual List Component",
6
6
  "author": "",
7
7
  "license": "MIT",