-
Notifications
You must be signed in to change notification settings - Fork 2.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
don't fire click event if default is prevented on mousedown for a dra…
…g event (#6697)
- Loading branch information
Showing
3 changed files
with
31 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -25,6 +25,7 @@ export default function bindHandlers(map: Map, options: {interactive: boolean}) | |
const el = map.getCanvasContainer(); | ||
let contextMenuEvent = null; | ||
let mouseDown = false; | ||
let startPos = null; | ||
|
||
for (const name in handlers) { | ||
(map: any)[name] = new handlers[name](map, options); | ||
|
@@ -56,6 +57,7 @@ export default function bindHandlers(map: Map, options: {interactive: boolean}) | |
|
||
function onMouseDown(e: MouseEvent) { | ||
mouseDown = true; | ||
startPos = DOM.mousePos(el, e); | ||
|
||
const mapEvent = new MapMouseEvent('mousedown', map, e); | ||
map.fire(mapEvent); | ||
|
@@ -149,7 +151,10 @@ export default function bindHandlers(map: Map, options: {interactive: boolean}) | |
} | ||
|
||
function onClick(e: MouseEvent) { | ||
map.fire(new MapMouseEvent('click', map, e)); | ||
const pos = DOM.mousePos(el, e); | ||
if (pos.equals(startPos)) { | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
Ready4theCrush
|
||
map.fire(new MapMouseEvent('click', map, e)); | ||
} | ||
} | ||
|
||
function onDblClick(e: MouseEvent) { | ||
|
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This logic essentially prevents the 'click' event from every firing (at least for me) I have a simple map with markers. Even if I leave the mouse in place over a marker and click the button without touching the track pad, the map still logs a slight movement and the 'click' event doesn't fire, no matter what. I've gone back to 0.44.2 to get the click events to fire, but wanted to let y'all know :-)