Skip to content

Commit

Permalink
feat: 新增 Popup overflowHIde 属性,用于控制 Marker 超出屏幕时是否触发隐藏
Browse files Browse the repository at this point in the history
  • Loading branch information
heiyexing committed Aug 15, 2024
1 parent 9333403 commit e8c65ce
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 3 deletions.
9 changes: 6 additions & 3 deletions packages/component/src/marker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ export default class Marker extends EventEmitter {
offsets: [0, 0],
color: '#5B8FF9',
draggable: false,
overflowHide: true,
};
}

Expand Down Expand Up @@ -348,9 +349,11 @@ export default class Marker extends EventEmitter {
pos.x = newPos.x;
}
}
// 不在当前可视区域内隐藏点
if (pos.x > containerWidth || pos.x < 0 || pos.y > containerHeight || pos.y < 0) {
element.style.display = 'none';
if (this.markerOption.overflowHide) {
// 不在当前可视区域内隐藏点
if (pos.x > containerWidth || pos.x < 0 || pos.y > containerHeight || pos.y < 0) {
element.style.display = 'none';
}
}

element.style.left = pos.x + offsets[0] + 'px';
Expand Down
1 change: 1 addition & 0 deletions packages/core/src/services/component/IMarkerService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ export interface IMarkerOption {
color: string;
offsets: number[];
draggable: boolean;
overflowHide?: boolean;
extData?: any;
style?: CSSStyleDeclaration;
}
Expand Down
1 change: 1 addition & 0 deletions site/docs/api/component/marker.zh.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ Marker
- element    `DOM|string`    自定义 marker DOM 节点,可以是 dom 实例,也可以是 dom id
- anchor     `string`  锚点位置   支持 center, top, top-left, top-right, bottom, bottom-left,bottom-right,left, right
- offsets    `Array`  偏移量  [ 0, 0 ] 分别表示 X, Y 的偏移量
- overflowHide   `boolean`  超出屏幕时是否隐藏 Marker,默认为 true
- draggable `boolean` 是否支持拖拽调整 Marker 位置
- extData 用户自定义属性,支持任意数据类型,存储 marker 属性信息

Expand Down

0 comments on commit e8c65ce

Please sign in to comment.