@jetlinks-web/components 3.1.9 → 3.1.10

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.
@@ -211,24 +211,32 @@ const __sfc_main__ = Object.assign({
211
211
  const onScroll = (e) => {
212
212
  const scrollTop = e.target.scrollTop;
213
213
  const vh = viewportHeight.value || 500;
214
+ const total = totalHeight.value;
215
+ // 防止 scrollTop 超出范围
216
+ const clampedScrollTop = Math.min(scrollTop, total - vh);
214
217
  // 二分查找
215
218
  let low = 0, high = prefixSum.value.length - 1;
216
219
  while (low < high) {
217
- let mid = Math.floor((low + high) / 2);
218
- if (prefixSum.value[mid] <= scrollTop)
220
+ const mid = Math.floor((low + high) / 2);
221
+ if (prefixSum.value[mid] <= clampedScrollTop)
219
222
  low = mid + 1;
220
223
  else
221
224
  high = mid;
222
225
  }
223
- start.value = Math.max(0, low - 1);
226
+ const newStart = Math.max(0, low - 1);
227
+ // 如果 start 没变化,直接跳过,避免重复计算导致闪动
228
+ if (newStart === start.value)
229
+ return;
230
+ start.value = newStart;
224
231
  // 计算 end
225
232
  let y = prefixSum.value[start.value] || 0;
226
233
  let i = start.value;
227
- while (i < visibleNodes.value.length && y < scrollTop + vh) {
234
+ while (i < visibleNodes.value.length && y < clampedScrollTop + vh) {
228
235
  y += rowHeights.value[i] || 40;
229
236
  i++;
230
237
  }
231
238
  end.value = Math.min(i + buffer, visibleNodes.value.length);
239
+ // 防止 offsetY 波动
232
240
  offsetY.value = prefixSum.value[start.value - 1] || 0;
233
241
  };
234
242
  const toggleExpand = (row) => {
@@ -258,6 +266,7 @@ const __sfc_main__ = Object.assign({
258
266
  const updateVisibleNodes = () => {
259
267
  visibleNodes.value = flattenData.value.filter(i => i.visible);
260
268
  updatePrefixSum();
269
+ console.log('123');
261
270
  nextTick(() => onScroll({ target: container.value }));
262
271
  };
263
272
  watch(() => [JSON.stringify(props.dataSource), JSON.stringify(props.expandedRowKeys)], () => {
@@ -211,24 +211,32 @@ const __sfc_main__ = Object.assign({
211
211
  const onScroll = (e) => {
212
212
  const scrollTop = e.target.scrollTop;
213
213
  const vh = viewportHeight.value || 500;
214
+ const total = totalHeight.value;
215
+ // 防止 scrollTop 超出范围
216
+ const clampedScrollTop = Math.min(scrollTop, total - vh);
214
217
  // 二分查找
215
218
  let low = 0, high = prefixSum.value.length - 1;
216
219
  while (low < high) {
217
- let mid = Math.floor((low + high) / 2);
218
- if (prefixSum.value[mid] <= scrollTop)
220
+ const mid = Math.floor((low + high) / 2);
221
+ if (prefixSum.value[mid] <= clampedScrollTop)
219
222
  low = mid + 1;
220
223
  else
221
224
  high = mid;
222
225
  }
223
- start.value = Math.max(0, low - 1);
226
+ const newStart = Math.max(0, low - 1);
227
+ // 如果 start 没变化,直接跳过,避免重复计算导致闪动
228
+ if (newStart === start.value)
229
+ return;
230
+ start.value = newStart;
224
231
  // 计算 end
225
232
  let y = prefixSum.value[start.value] || 0;
226
233
  let i = start.value;
227
- while (i < visibleNodes.value.length && y < scrollTop + vh) {
234
+ while (i < visibleNodes.value.length && y < clampedScrollTop + vh) {
228
235
  y += rowHeights.value[i] || 40;
229
236
  i++;
230
237
  }
231
238
  end.value = Math.min(i + buffer, visibleNodes.value.length);
239
+ // 防止 offsetY 波动
232
240
  offsetY.value = prefixSum.value[start.value - 1] || 0;
233
241
  };
234
242
  const toggleExpand = (row) => {
@@ -258,6 +266,7 @@ const __sfc_main__ = Object.assign({
258
266
  const updateVisibleNodes = () => {
259
267
  visibleNodes.value = flattenData.value.filter(i => i.visible);
260
268
  updatePrefixSum();
269
+ console.log('123');
261
270
  nextTick(() => onScroll({ target: container.value }));
262
271
  };
263
272
  watch(() => [JSON.stringify(props.dataSource), JSON.stringify(props.expandedRowKeys)], () => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jetlinks-web/components",
3
- "version": "3.1.9",
3
+ "version": "3.1.10",
4
4
  "description": "",
5
5
  "main": "lib/index.js",
6
6
  "module": "es/index.js",