huweili-cesium 1.2.53 → 1.2.55

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.
Files changed (2) hide show
  1. package/js/basis.js +35 -3
  2. package/package.json +1 -1
package/js/basis.js CHANGED
@@ -763,15 +763,47 @@ export function basicConfig() {
763
763
  const defaultVisibleTitles = ['展开/折叠 工具栏', '展开', '收缩', '指北针', '2D/3D视角切换', '降低视角', '抬升视角', '更多', '收起更多']
764
764
  let isMoreExpanded = false
765
765
 
766
+ const isTruthyAttr = (value) => value === true || value === 'true' || value === ''
767
+
766
768
  const isDefaultVisibleToolbarItem = (item) => {
767
- const title = item?.getAttribute?.('title') || item?.title || ''
768
- const text = item?.textContent?.trim() || ''
769
- return item?.dataset?.toolbarDragReady === 'true' || defaultVisibleTitles.includes(title) || text.includes('更多')
769
+ if (!item) return false
770
+
771
+ const dataset = item.dataset || {}
772
+ const isMarkedDefaultVisible = isTruthyAttr(dataset.toolbarDefaultVisible)
773
+ || isTruthyAttr(item.getAttribute?.('data-toolbar-default-visible'))
774
+ || isTruthyAttr(item.getAttribute?.('isDefaultVisible'))
775
+ || isTruthyAttr(item.getAttribute?.('is-default-visible'))
776
+
777
+ const isMarkedMoreToggle = isTruthyAttr(dataset.toolbarMoreToggle)
778
+ || isTruthyAttr(item.getAttribute?.('data-toolbar-more-toggle'))
779
+ || isTruthyAttr(item.getAttribute?.('isMoreToggle'))
780
+ || isTruthyAttr(item.getAttribute?.('is-more-toggle'))
781
+
782
+ if (isMarkedDefaultVisible || isMarkedMoreToggle || dataset.toolbarDragReady === 'true') return true
783
+
784
+ const title = item.getAttribute?.('title') || item.title || ''
785
+ const text = item.textContent?.trim() || ''
786
+ return defaultVisibleTitles.includes(title) || text.includes('更多')
787
+ }
788
+
789
+ const lockToolbarCurrentPosition = (toolbar) => {
790
+ if (!toolbar || typeof window === 'undefined') return
791
+
792
+ const rect = toolbar.getBoundingClientRect()
793
+ toolbar.style.position = 'fixed'
794
+ toolbar.style.left = `${Math.max(rect.left, 0)}px`
795
+ toolbar.style.top = `${Math.max(rect.top, 0)}px`
796
+ toolbar.style.right = 'auto'
797
+ toolbar.style.bottom = 'auto'
798
+ toolbar.style.zIndex = toolbar.style.zIndex || '9999'
799
+ toolbar.style.margin = '0'
770
800
  }
771
801
 
772
802
  const applyMoreVisible = (toolbar, expanded) => {
773
803
  if (!toolbar) return
774
804
 
805
+ lockToolbarCurrentPosition(toolbar)
806
+
775
807
  Array.from(toolbar.children).forEach((item) => {
776
808
  const isDefaultVisible = isDefaultVisibleToolbarItem(item)
777
809
  item.style.display = expanded || isDefaultVisible ? '' : 'none'
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "huweili-cesium",
3
- "version": "1.2.53",
3
+ "version": "1.2.55",
4
4
  "description": "基于 Cesium 的地图工具库(无人机态势、轨迹、围栏、工具栏等)",
5
5
  "type": "module",
6
6
  "main": "./index.js",