huweili-cesium 1.2.46 → 1.2.47
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 +18 -25
- package/package.json +1 -1
package/js/basis.js
CHANGED
|
@@ -874,10 +874,17 @@ export function basicConfig() {
|
|
|
874
874
|
}
|
|
875
875
|
|
|
876
876
|
const applyToolbarPosition = (toolbar, left, top) => {
|
|
877
|
-
if (!toolbar) return
|
|
877
|
+
if (!toolbar) return false
|
|
878
|
+
|
|
879
|
+
const toolbarWidth = toolbar.offsetWidth
|
|
880
|
+
const toolbarHeight = toolbar.offsetHeight
|
|
881
|
+
const viewportWidth = window.innerWidth
|
|
882
|
+
const viewportHeight = window.innerHeight
|
|
883
|
+
|
|
884
|
+
if (!toolbarWidth || !toolbarHeight || !viewportWidth || !viewportHeight) return false
|
|
878
885
|
|
|
879
|
-
const maxLeft =
|
|
880
|
-
const maxTop =
|
|
886
|
+
const maxLeft = viewportWidth - toolbarWidth
|
|
887
|
+
const maxTop = viewportHeight - toolbarHeight
|
|
881
888
|
const nextLeft = Math.min(Math.max(left, 0), Math.max(maxLeft, 0))
|
|
882
889
|
const nextTop = Math.min(Math.max(top, 0), Math.max(maxTop, 0))
|
|
883
890
|
|
|
@@ -888,6 +895,7 @@ export function basicConfig() {
|
|
|
888
895
|
toolbar.style.bottom = 'auto'
|
|
889
896
|
toolbar.style.zIndex = toolbar.style.zIndex || '9999'
|
|
890
897
|
toolbar.style.margin = '0'
|
|
898
|
+
return true
|
|
891
899
|
}
|
|
892
900
|
|
|
893
901
|
const restoreToolbarPosition = (btn) => {
|
|
@@ -898,7 +906,12 @@ export function basicConfig() {
|
|
|
898
906
|
if (!position) return
|
|
899
907
|
|
|
900
908
|
window.requestAnimationFrame(() => {
|
|
901
|
-
applyToolbarPosition(toolbar, position.left, position.top)
|
|
909
|
+
const restored = applyToolbarPosition(toolbar, position.left, position.top)
|
|
910
|
+
if (!restored) {
|
|
911
|
+
window.setTimeout(() => {
|
|
912
|
+
applyToolbarPosition(toolbar, position.left, position.top)
|
|
913
|
+
}, 100)
|
|
914
|
+
}
|
|
902
915
|
})
|
|
903
916
|
}
|
|
904
917
|
|
|
@@ -982,29 +995,9 @@ export function basicConfig() {
|
|
|
982
995
|
})
|
|
983
996
|
}
|
|
984
997
|
|
|
985
|
-
const findExpandButton = () => {
|
|
986
|
-
return document.querySelector('[data-toolbar-expand-toggle="true"]')
|
|
987
|
-
|| document.querySelector('[title="展开/折叠 工具栏"]')
|
|
988
|
-
|| document.querySelector('[title="展开"]')
|
|
989
|
-
|| document.querySelector('[title="收缩"]')
|
|
990
|
-
}
|
|
991
|
-
|
|
992
|
-
const setupBySelector = () => {
|
|
993
|
-
const btn = findExpandButton()
|
|
994
|
-
if (btn) setupToolbarDrag(btn)
|
|
995
|
-
}
|
|
996
|
-
|
|
997
|
-
if (typeof window !== 'undefined' && typeof document !== 'undefined') {
|
|
998
|
-
window.requestAnimationFrame(setupBySelector)
|
|
999
|
-
window.setTimeout(setupBySelector, 300)
|
|
1000
|
-
}
|
|
1001
|
-
|
|
1002
998
|
return {
|
|
1003
999
|
toggleExpand: (_viewer, btn) => {
|
|
1004
|
-
if (btn)
|
|
1005
|
-
btn.dataset.toolbarExpandToggle = 'true'
|
|
1006
|
-
setupToolbarDrag(btn)
|
|
1007
|
-
}
|
|
1000
|
+
if (btn) setupToolbarDrag(btn)
|
|
1008
1001
|
},
|
|
1009
1002
|
setupToolbarDrag,
|
|
1010
1003
|
applyToggleExpand,
|