huweili-cesium 1.2.89 → 1.2.90
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.
|
@@ -54,6 +54,9 @@ export function createBasemapSwitcher() {
|
|
|
54
54
|
if (!viewer?.container) return
|
|
55
55
|
|
|
56
56
|
const PANEL_ID = 'cesium-basemap-picker-panel'
|
|
57
|
+
/** 面板相对锚点的微调(工具栏靠右下时避免溢出视口) */
|
|
58
|
+
const PANEL_POSITION_OFFSET = { top: -26, left: -2 }
|
|
59
|
+
const PANEL_GAP = 8
|
|
57
60
|
let panel = document.getElementById(PANEL_ID)
|
|
58
61
|
|
|
59
62
|
const syncPanelViewport = () => {
|
|
@@ -63,16 +66,27 @@ export function createBasemapSwitcher() {
|
|
|
63
66
|
|
|
64
67
|
const margin = 35
|
|
65
68
|
const panelRect = panel.getBoundingClientRect()
|
|
66
|
-
const toolbar = document.querySelector('.cesium-viewer-toolbar')
|
|
67
|
-
const toolbarRect = toolbar?.getBoundingClientRect()
|
|
68
69
|
|
|
69
|
-
|
|
70
|
-
let
|
|
70
|
+
// 默认:面板在触发按钮左上方展开(适配右下工具栏)
|
|
71
|
+
let left = buttonRect.left - panelRect.width - PANEL_GAP
|
|
72
|
+
let top = buttonRect.top - panelRect.height
|
|
71
73
|
|
|
72
|
-
|
|
73
|
-
if (
|
|
74
|
+
// 左侧放不下时,改到按钮右侧
|
|
75
|
+
if (left < margin) {
|
|
76
|
+
left = buttonRect.right + PANEL_GAP
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
if (top < margin) top = margin
|
|
80
|
+
if (top + panelRect.height > window.innerHeight - margin) {
|
|
74
81
|
top = window.innerHeight - panelRect.height - margin
|
|
75
82
|
}
|
|
83
|
+
if (left + panelRect.width > window.innerWidth - margin) {
|
|
84
|
+
left = window.innerWidth - panelRect.width - margin
|
|
85
|
+
}
|
|
86
|
+
if (left < margin) left = margin
|
|
87
|
+
|
|
88
|
+
left += PANEL_POSITION_OFFSET.left
|
|
89
|
+
top += PANEL_POSITION_OFFSET.top
|
|
76
90
|
|
|
77
91
|
panel.style.position = 'fixed'
|
|
78
92
|
panel.style.right = 'auto'
|
|
@@ -53,6 +53,9 @@ export function createBasemapSwitcher() {
|
|
|
53
53
|
if (!viewer?.container) return
|
|
54
54
|
|
|
55
55
|
const PANEL_ID = 'cesium-basemap-picker-panel'
|
|
56
|
+
/** 面板相对锚点的微调(工具栏靠右下时避免溢出视口) */
|
|
57
|
+
const PANEL_POSITION_OFFSET = { top: -26, left: -2 }
|
|
58
|
+
const PANEL_GAP = 8
|
|
56
59
|
let panel = document.getElementById(PANEL_ID)
|
|
57
60
|
|
|
58
61
|
const syncPanelViewport = () => {
|
|
@@ -62,16 +65,27 @@ export function createBasemapSwitcher() {
|
|
|
62
65
|
|
|
63
66
|
const margin = 35
|
|
64
67
|
const panelRect = panel.getBoundingClientRect()
|
|
65
|
-
const toolbar = document.querySelector('.cesium-viewer-toolbar')
|
|
66
|
-
const toolbarRect = toolbar?.getBoundingClientRect()
|
|
67
68
|
|
|
68
|
-
|
|
69
|
-
let
|
|
69
|
+
// 默认:面板在触发按钮左上方展开(适配右下工具栏)
|
|
70
|
+
let left = buttonRect.left - panelRect.width - PANEL_GAP
|
|
71
|
+
let top = buttonRect.top - panelRect.height
|
|
70
72
|
|
|
71
|
-
|
|
72
|
-
if (
|
|
73
|
+
// 左侧放不下时,改到按钮右侧
|
|
74
|
+
if (left < margin) {
|
|
75
|
+
left = buttonRect.right + PANEL_GAP
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
if (top < margin) top = margin
|
|
79
|
+
if (top + panelRect.height > window.innerHeight - margin) {
|
|
73
80
|
top = window.innerHeight - panelRect.height - margin
|
|
74
81
|
}
|
|
82
|
+
if (left + panelRect.width > window.innerWidth - margin) {
|
|
83
|
+
left = window.innerWidth - panelRect.width - margin
|
|
84
|
+
}
|
|
85
|
+
if (left < margin) left = margin
|
|
86
|
+
|
|
87
|
+
left += PANEL_POSITION_OFFSET.left
|
|
88
|
+
top += PANEL_POSITION_OFFSET.top
|
|
75
89
|
|
|
76
90
|
panel.style.position = 'fixed'
|
|
77
91
|
panel.style.right = 'auto'
|