Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add hideOnMove option to allow map to move without hiding context menu #282

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,7 @@ contextmenu.on('open', function (evt) {
- `defaultItems`: `true`; Whether the default items (which are: Zoom In/Out) are enabled
- `width`: `150`; The menu's width
- `items`: `[]`; An array of object|string
- `hideOnMove`: `true`; Whether the context menu should hide when the map moves as a result of user iteraction or programmatically.

## Methods

Expand Down
1 change: 1 addition & 0 deletions src/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ export const DEFAULT_OPTIONS: Options = {
eventType: EventTypes.CONTEXTMENU,
defaultItems: true,
items: [],
hideOnMove: true,
};

const NAMESPACE = 'ol-ctx-menu';
Expand Down
4 changes: 3 additions & 1 deletion src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -399,7 +399,9 @@ export default class ContextMenu extends Control {
}

protected handleMapMove() {
this.closeMenu();
if (this.options.hideOnMove) {
this.closeMenu();
}
}

protected handleEntryCallback(evt: MouseEvent) {
Expand Down
1 change: 1 addition & 0 deletions src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,4 +64,5 @@ export type Options = {
eventType: `${EventTypes}`;
defaultItems: boolean;
items: Item[];
hideOnMove?: boolean;
};