box zoom logic recognizing very small mousemove distances as the start of a zoom gesture #5241

hanginwithdaddo opened this Issue Jan 10, 2017 · 0 comments


None yet

1 participant

hanginwithdaddo commented Jan 10, 2017 edited
  • I'm reporting a bug, not asking for help
  • I've looked at the documentation to make sure the behaviour is documented and expected
  • I'm sure this is a Leaflet code issue, not an issue with my own code nor with the framework I'm using (Cordova, Ionic, Angular, React…)
  • I've searched through the issues to make sure it's not yet reported

This issue can be seen when:

  1. Setting the map's doubleClickZoom option to false and its boxZoom option to true.
  2. Pressing the shift key and then double clicking the map.

If the mouse moves just the tiniest bit between one of the mousedown and mouseup events, this is interpreted as the start of drawing a box for zooming and the map zooms into the very tiny region resulting from the interpreted drag gesture.

The problem seems to be that there is no test in Leaflet's mousemove listener that applies when the box zoom feature is enabled to avoid interpreting small movements as drag gestures. Below is the section of code from 0.7.7's leaflet-src.js, starting at about line 7576, where this problem occurs.

_onMouseMove: function (e) {
	if (!this._moved) {
		this._box = L.DomUtil.create('div', 'leaflet-zoom-box', this._pane);
		L.DomUtil.setPosition(this._box, this._startLayerPoint);

		//TODO refactor: move cursor to styles = 'crosshair';'boxzoomstart');

There isn't a test to see if the mouse has actually moved a significant amount like there is in other places of the leaflet source to ensure that the mouse movement really represents a drag gesture.

  • Leaflet version I'm using: 0.7.7 and 1.0.1
  • Browser (with version) I'm using: Chrome Version 55.0.2883.87 m
  • OS/Platform (with version) I'm using: Windows 7 or OSX
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment