feat: add camera switch, fix click event/dialog resize/map state sync
- fix(engine): adapt click handler to base engine array format data[0].url/ids - feat(toolbar): add perspective/orthographic camera switch button with dynamic icon - fix(dialog): clamp resize to container bounds to prevent overflow - feat(demo): add auto-combine feature with robust URL parsing and validation - fix(walk): close minimap on walk exit and sync map state between toolbar and walk panel - fix(engine): correct MiniMap getstate() casing to match base engine API - build: rebuild demo libs
This commit is contained in:
@@ -425,6 +425,10 @@ export class BimDialog implements IBimComponent {
|
||||
let startY = 0;
|
||||
let startW = 0;
|
||||
let startH = 0;
|
||||
let containerW = 0;
|
||||
let containerH = 0;
|
||||
let elLeft = 0;
|
||||
let elTop = 0;
|
||||
|
||||
const onMouseDown = (e: MouseEvent) => {
|
||||
e.preventDefault();
|
||||
@@ -434,6 +438,12 @@ export class BimDialog implements IBimComponent {
|
||||
startW = this.element.offsetWidth;
|
||||
startH = this.element.offsetHeight;
|
||||
|
||||
// 缓存容器尺寸和弹窗位置,用于计算最大可缩放范围
|
||||
containerW = this.container.clientWidth;
|
||||
containerH = this.container.clientHeight;
|
||||
elLeft = this.element.offsetLeft;
|
||||
elTop = this.element.offsetTop;
|
||||
|
||||
// 关键:使用 capture: true
|
||||
document.addEventListener('mousemove', onMouseMove, { capture: true });
|
||||
document.addEventListener('mouseup', onMouseUp, { capture: true });
|
||||
@@ -449,8 +459,12 @@ export class BimDialog implements IBimComponent {
|
||||
const dx = e.clientX - startX;
|
||||
const dy = e.clientY - startY;
|
||||
|
||||
const newW = Math.max(this.options.minWidth || 100, startW + dx);
|
||||
const newH = Math.max(this.options.minHeight || 50, startH + dy);
|
||||
// 最大宽高:不超出容器右边界/下边界
|
||||
const maxW = containerW - elLeft;
|
||||
const maxH = containerH - elTop;
|
||||
|
||||
const newW = Math.min(maxW, Math.max(this.options.minWidth || 100, startW + dx));
|
||||
const newH = Math.min(maxH, Math.max(this.options.minHeight || 50, startH + dy));
|
||||
|
||||
this.element.style.width = `${newW}px`;
|
||||
this.element.style.height = `${newH}px`;
|
||||
|
||||
Reference in New Issue
Block a user