dfish-widget 1.0.50 → 1.0.51

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/lib/index.esm.js CHANGED
@@ -6092,7 +6092,7 @@ const props = __props;
6092
6092
 
6093
6093
 
6094
6094
 
6095
- const {alias, itemHeight} = props;
6095
+ let {alias, itemHeight, current} = props;
6096
6096
 
6097
6097
  const propValue = alias.value || 'id';
6098
6098
  const propText = alias.text || 'text';
@@ -6256,18 +6256,18 @@ const props = __props;
6256
6256
  showCount.value = Math.ceil(flow.value.height / itemHeight);
6257
6257
  };
6258
6258
 
6259
- const watchCurrent = async (current) => {
6260
- await nextTick();
6261
- if (!showList.value.find(n => n[propValue] === current)) {
6262
- const item = expandTo(current);
6263
- const i = flatList.value.indexOf(item);
6264
- if (i > -1) {
6265
- nextTick(() => {
6266
- root.value.scrollToY(((i + 1) * itemHeight) - (flow.value.height / 2));
6267
- });
6268
- }
6259
+ const watchCurrent = async (val) => {
6260
+ await nextTick();
6261
+ current = val;
6262
+ if (!showList.value.find(n => n[propValue] === val)) {
6263
+ const item = expandTo(val);
6264
+ const i = flatList.value.indexOf(item);
6265
+ if (i > -1) {
6266
+ await nextTick();
6267
+ root.value.scrollToY(((i + 1) * itemHeight) - (flow.value.height / 2));
6269
6268
  }
6270
- };
6269
+ }
6270
+ };
6271
6271
 
6272
6272
  onMounted(async () => {
6273
6273
  watch(() => root.value.wScrollSizeY, (ssy) => {
@@ -6275,7 +6275,7 @@ const props = __props;
6275
6275
  }, {immediate: true});
6276
6276
  watch(() => props.children, async (children) => {
6277
6277
  flatList.value = toFlat(children);
6278
- if (props.current) {
6278
+ if (current && current == props.current) { // 避免重复聚焦
6279
6279
  watchCurrent(props.current);
6280
6280
  }
6281
6281
  }, {immediate: true});