react-map-gl icon indicating copy to clipboard operation
react-map-gl copied to clipboard

mouseDown event sets isDragging to true

Open JamesWooldridge opened this issue 10 years ago • 3 comments

@autobind _onMouseDown({pos}) {
    const map = this._getMap();
    const lngLat = unprojectFromTransform(map.transform, pos);
    this._callOnChangeViewport(map.transform, {
      isDragging: true,  // **** HERE
      startDragLngLat: [lngLat.lng, lngLat.lat],
      startBearing: map.transform.bearing,
      startPitch: map.transform.pitch
    });
  }

Currently, clicking the map causes isDragging to be set to true. I'm not sure why mouseDown should be considered a drag, especially when there's a specific mouseDrag handler that also sets isDragging to true. To me they're fundamentally different actions.

A use case supporting this is if you use isDragging to decide whether to render an overlay (e.g. for performance). It's impossible to have click events on elements in your overlay (since they disappear on mouseDown).

Would it be more appropriate to only set isDragging = true on mouseDrag rather than mouseDown? (or, is there another way to handle this altogether?)

Edit: I'm also happy to submit a PR changing this

JamesWooldridge avatar Nov 18 '16 04:11 JamesWooldridge

Not sure about this too, will investigate.

balthazar avatar Dec 03 '16 03:12 balthazar

The isDragging prop is really a state internal to the MapGL component, not meant to be consumed by the user. The reason it is exposed has to do with the original design intent to keep MapGL a stat-less component. It'd be less confusing if this prop was named isMouseDown.

Pessimistress avatar Jan 09 '17 23:01 Pessimistress

The whole Map component has been moved to the deprecate folder, so closing.

howtimeflies0 avatar May 10 '17 18:05 howtimeflies0