dfish-widget 1.0.49 → 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';
@@ -6237,9 +6237,9 @@ const props = __props;
6237
6237
  a = p;
6238
6238
  }
6239
6239
  }
6240
- a && toggle(a, true);
6241
- return item
6240
+ a && doToggle(a, true);
6242
6241
  }
6242
+ return item
6243
6243
  };
6244
6244
 
6245
6245
  const showList = computed(() => {
@@ -6256,24 +6256,30 @@ const props = __props;
6256
6256
  showCount.value = Math.ceil(flow.value.height / itemHeight);
6257
6257
  };
6258
6258
 
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));
6268
+ }
6269
+ }
6270
+ };
6271
+
6259
6272
  onMounted(async () => {
6260
6273
  watch(() => root.value.wScrollSizeY, (ssy) => {
6261
6274
  initShowCount();
6262
6275
  }, {immediate: true});
6263
- watch(() => props.children, (children) => {
6276
+ watch(() => props.children, async (children) => {
6264
6277
  flatList.value = toFlat(children);
6265
- }, {immediate: true});
6266
- watch(() => props.current, (current) => {
6267
- if (!showList.value.find(n => n[propValue] === current)) {
6268
- const item = expandTo(current);
6269
- const i = flatList.value.indexOf(item);
6270
- if (i > -1) {
6271
- nextTick(() => {
6272
- root.value.scrollToY(((i + 1) * itemHeight) - (flow.value.height / 2));
6273
- });
6274
- }
6278
+ if (current && current == props.current) { // 避免重复聚焦
6279
+ watchCurrent(props.current);
6275
6280
  }
6276
- });
6281
+ }, {immediate: true});
6282
+ watch(() => props.current, watchCurrent);
6277
6283
  const src = props.src && props.src();
6278
6284
  if (src) {
6279
6285
  loading.value = true;