Skip to content

Commit

Permalink
feat: Marker 新增 overflowHIde 属性,支持控制超出屏幕时是否触发隐藏 (#2592)
Browse files Browse the repository at this point in the history
* feat: 新增 Popup overflowHIde 属性,用于控制 Marker 超出屏幕时是否触发隐藏

* chore: add changeset

* chore: format code style

* chore(CI): update snapshots (#2593)

Co-authored-by: lvisei <[email protected]>

---------

Co-authored-by: lvisei <[email protected]>
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: lvisei <[email protected]>
  • Loading branch information
4 people authored Aug 15, 2024
1 parent 7e35485 commit c21ea5b
Show file tree
Hide file tree
Showing 7 changed files with 15 additions and 5 deletions.
5 changes: 5 additions & 0 deletions .changeset/gentle-teachers-smile.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@antv/l7-component': patch
---

feat: Marker 新增 overflowHIde 属性,支持控制超出屏幕时是否触发隐藏
Binary file modified __tests__/integration/snapshots/gallery_fujian.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified __tests__/integration/snapshots/point_text.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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
4 changes: 2 additions & 2 deletions packages/maps/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,9 @@ export {
GaodeMapV2,
GoogleMap,
Map,
Mapbox,
MapLibre,
MapType,
Mapbox,
TMap,
TencentMap,
TMap,
};
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 c21ea5b

Please sign in to comment.