Skip to content

Commit 51f9221

Browse files
authored
Merge pull request #79 from eddydg/bugfix/overlapping-events
Prevent overlapping mouse down events
2 parents 453b467 + 2835632 commit 51f9221

2 files changed

Lines changed: 15 additions & 0 deletions

File tree

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -191,6 +191,7 @@ Returns **{sw: {lat: [number](https://developer.mozilla.org/docs/Web/JavaScript/
191191
### v. 1.6.7
192192

193193
- `optionalDependencies` removed from `package.json`, making this package easier to depend on ([#82](https://github.com/smithmicro/mapbox-gl-circle/issues/82))
194+
- Bug fix for overlapping mouse-down events, causing the edit handle to lock until the user performs a full page refresh ([#80](https://github.com/smithmicro/mapbox-gl-circle/issues/80))
194195

195196
### v. 1.6.6
196197

lib/main.js

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -501,6 +501,9 @@ class MapboxCircle {
501501
* @private
502502
*/
503503
_onCenterHandleMouseDown() {
504+
if (this._getCursorStyle() !== 'move') {
505+
/* Only trigger center edit event if the user expects it. */ return;
506+
}
504507
this._centerDragActive = true;
505508
this._mapOnDebounced('mousemove', this._onCenterHandleMouseMove);
506509
this.map.addLayer(this._getCenterHandleStrokeLayer(), this._circleCenterHandleId);
@@ -640,6 +643,9 @@ class MapboxCircle {
640643
* @private
641644
*/
642645
_onRadiusHandlesMouseDown(event) {
646+
if (!this._getCursorStyle().endsWith('-resize')) {
647+
/* Only trigger radius edit event if the user expects it. */ return;
648+
}
643649
this._radiusDragActive = true;
644650
this._mapOnDebounced('mousemove', this._onRadiusHandlesMouseMove);
645651
this.map.addLayer(this._getRadiusHandlesStrokeLayer(), this._circleRadiusHandlesId);
@@ -1115,6 +1121,14 @@ class MapboxCircle {
11151121
};
11161122
}
11171123

1124+
/**
1125+
* @return {string} Current cursor style
1126+
* @private
1127+
*/
1128+
_getCursorStyle() {
1129+
return this.map.getCanvas().style.cursor;
1130+
}
1131+
11181132
/**
11191133
* Subscribe to circle event.
11201134
* @param {string} event Event name; `click`, `contextmenu`, `centerchanged` or `radiuschanged`

0 commit comments

Comments
 (0)