@handaotech-design/bom 0.0.46 → 0.0.48

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.
@@ -56,6 +56,7 @@ const displayTreeData = computed(() => {
56
56
  })
57
57
  const isPreservingTreeState = ref<boolean>(false)
58
58
  const isAutoLoadingRoots = ref(false)
59
+ let isProgrammaticScroll = false
59
60
  const searchMatches = ref<string[]>([])
60
61
  const currentMatchIndex = ref(0)
61
62
  const initTreeState = () => {
@@ -102,6 +103,7 @@ async function locateNodeByKey(targetKey: string) {
102
103
  if (!targetKey) {
103
104
  return
104
105
  }
106
+ isProgrammaticScroll = true
105
107
  ensureRootVisibleByKey(targetKey)
106
108
  const parentKeys = getParentKeys(targetKey) || []
107
109
  expandedKeys.value = Array.from(new Set([
@@ -114,7 +116,14 @@ async function locateNodeByKey(targetKey: string) {
114
116
  key: targetKey,
115
117
  align: 'top',
116
118
  })
117
- focusNode(targetKey)
119
+ setTimeout(() => {
120
+ focusNode(targetKey)
121
+ }, 0) // 延时足够滚动完成
122
+ requestAnimationFrame(() => {
123
+ setTimeout(() => {
124
+ isProgrammaticScroll = false
125
+ }, 500) // 延时足够滚动完成
126
+ })
118
127
  }
119
128
 
120
129
  const scrollToMatch = async (index: number) => {
@@ -309,7 +318,7 @@ const loadMoreRoot = () => {
309
318
  }
310
319
 
311
320
  const maybeAutoLoadMoreRoot = () => {
312
- if (isAutoLoadingRoots.value || !canLoadMoreRoot.value) {
321
+ if (isAutoLoadingRoots.value || !canLoadMoreRoot.value || isProgrammaticScroll) {
313
322
  return
314
323
  }
315
324
  const container = treeContainerRef.value
@@ -357,6 +366,10 @@ async function _loadData(node: EventDataNode) {
357
366
  }
358
367
 
359
368
  function focusNode(key: string) {
369
+ // 先清理页面上已有的焦点动画
370
+ document.querySelectorAll<HTMLElement>('.tree-node-tittle.focus-flash').forEach((el) => {
371
+ el.classList.remove('focus-flash')
372
+ })
360
373
  // 1. 用 antd Tree 自带滚动
361
374
  treeRef.value?.scrollTo({ key, align: 'center' })
362
375
 
@@ -56,6 +56,7 @@ const displayTreeData = computed(() => {
56
56
  })
57
57
  const isPreservingTreeState = ref<boolean>(false)
58
58
  const isAutoLoadingRoots = ref(false)
59
+ let isProgrammaticScroll = false
59
60
  const searchMatches = ref<string[]>([])
60
61
  const currentMatchIndex = ref(0)
61
62
  const initTreeState = () => {
@@ -102,6 +103,7 @@ async function locateNodeByKey(targetKey: string) {
102
103
  if (!targetKey) {
103
104
  return
104
105
  }
106
+ isProgrammaticScroll = true
105
107
  ensureRootVisibleByKey(targetKey)
106
108
  const parentKeys = getParentKeys(targetKey) || []
107
109
  expandedKeys.value = Array.from(new Set([
@@ -114,7 +116,14 @@ async function locateNodeByKey(targetKey: string) {
114
116
  key: targetKey,
115
117
  align: 'top',
116
118
  })
117
- focusNode(targetKey)
119
+ setTimeout(() => {
120
+ focusNode(targetKey)
121
+ }, 0) // 延时足够滚动完成
122
+ requestAnimationFrame(() => {
123
+ setTimeout(() => {
124
+ isProgrammaticScroll = false
125
+ }, 500) // 延时足够滚动完成
126
+ })
118
127
  }
119
128
 
120
129
  const scrollToMatch = async (index: number) => {
@@ -309,7 +318,7 @@ const loadMoreRoot = () => {
309
318
  }
310
319
 
311
320
  const maybeAutoLoadMoreRoot = () => {
312
- if (isAutoLoadingRoots.value || !canLoadMoreRoot.value) {
321
+ if (isAutoLoadingRoots.value || !canLoadMoreRoot.value || isProgrammaticScroll) {
313
322
  return
314
323
  }
315
324
  const container = treeContainerRef.value
@@ -357,6 +366,10 @@ async function _loadData(node: EventDataNode) {
357
366
  }
358
367
 
359
368
  function focusNode(key: string) {
369
+ // 先清理页面上已有的焦点动画
370
+ document.querySelectorAll<HTMLElement>('.tree-node-tittle.focus-flash').forEach((el) => {
371
+ el.classList.remove('focus-flash')
372
+ })
360
373
  // 1. 用 antd Tree 自带滚动
361
374
  treeRef.value?.scrollTo({ key, align: 'center' })
362
375
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@handaotech-design/bom",
3
- "version": "0.0.46",
3
+ "version": "0.0.48",
4
4
  "license": "MIT",
5
5
  "sideEffects": false,
6
6
  "exports": {