huweili-cesium 1.2.47 → 1.2.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.
- package/js/basis.js +31 -0
- package/package.json +1 -1
package/js/basis.js
CHANGED
|
@@ -834,6 +834,8 @@ export function basicConfig() {
|
|
|
834
834
|
*/
|
|
835
835
|
const createToolbarExpandController = ({
|
|
836
836
|
storageKey = 'huweili-cesium-toolbar-position',
|
|
837
|
+
toggleIconSrc = '',
|
|
838
|
+
autoRestore = true,
|
|
837
839
|
} = {}) => {
|
|
838
840
|
let isToolbarExpanded = true
|
|
839
841
|
let isToolbarDragging = false
|
|
@@ -995,12 +997,41 @@ export function basicConfig() {
|
|
|
995
997
|
})
|
|
996
998
|
}
|
|
997
999
|
|
|
1000
|
+
const findExpandButtonByIcon = () => {
|
|
1001
|
+
if (!toggleIconSrc || typeof document === 'undefined') return null
|
|
1002
|
+
|
|
1003
|
+
const images = Array.from(document.querySelectorAll('img'))
|
|
1004
|
+
const icon = images.find((img) => img.src?.includes(toggleIconSrc) || img.getAttribute('src')?.includes(toggleIconSrc))
|
|
1005
|
+
if (!icon) return null
|
|
1006
|
+
|
|
1007
|
+
return icon.closest('button') || icon.parentElement
|
|
1008
|
+
}
|
|
1009
|
+
|
|
1010
|
+
const autoRestoreToolbarPosition = (retryCount = 0) => {
|
|
1011
|
+
if (!autoRestore || typeof window === 'undefined') return
|
|
1012
|
+
|
|
1013
|
+
const btn = findExpandButtonByIcon()
|
|
1014
|
+
if (btn) {
|
|
1015
|
+
setupToolbarDrag(btn)
|
|
1016
|
+
return
|
|
1017
|
+
}
|
|
1018
|
+
|
|
1019
|
+
if (retryCount < 20) {
|
|
1020
|
+
window.setTimeout(() => autoRestoreToolbarPosition(retryCount + 1), 100)
|
|
1021
|
+
}
|
|
1022
|
+
}
|
|
1023
|
+
|
|
1024
|
+
if (autoRestore && typeof window !== 'undefined') {
|
|
1025
|
+
window.requestAnimationFrame(() => autoRestoreToolbarPosition())
|
|
1026
|
+
}
|
|
1027
|
+
|
|
998
1028
|
return {
|
|
999
1029
|
toggleExpand: (_viewer, btn) => {
|
|
1000
1030
|
if (btn) setupToolbarDrag(btn)
|
|
1001
1031
|
},
|
|
1002
1032
|
setupToolbarDrag,
|
|
1003
1033
|
applyToggleExpand,
|
|
1034
|
+
restoreToolbarPosition,
|
|
1004
1035
|
}
|
|
1005
1036
|
}
|
|
1006
1037
|
|