OpenTreeMap / otm-core

OpenTreeMap is a collaborative platform for crowdsourced tree inventory, ecosystem services calculations, urban forestry analysis, and community engagement.
www.opentreemap.org
Other
186 stars 88 forks source link

Monkey patch the Leaflet layer selector to work in Mobile Safari #3253

Closed jwalgran closed 6 years ago

jwalgran commented 6 years ago

Overview

Tapping on the layers control in Mobile Safari was not opening the layer selector. I was not able to reproduce this issue in a separate test application, only within OTM.

After much trial and error I discovered that changing this line

  L.DomEvent.on(el, L.Draggable.START.join(' '), stop);

to

  L.DomEvent.on(container, 'mousedown', stop);

in DomEvent.disableClickPropagation resolved the issue. Effectively, this prevents the touchstart event from being stopped.

I opted to implement this as a runtime patch applied within MapManager instead of a global patch to the Leaflet source because there are no other Leaflet behaviors that are known to be broken in Mobile Safari and I did not want to risk introducing a regression in some other event handling.

I minimized the chance of forgetting about this patch if/when we upgrade our version of Leaflet by adding a comment to package.json.

Connects #3250

Testing Instructions

Setup

Test

jwalgran commented 6 years ago

The comment in the dependency section of the package.json file did not work. I am going to try moving it up to the top level.

coveralls commented 6 years ago

Coverage Status

Coverage remained the same at 83.796% when pulling e89ebf259a503b9b7f271fe312fc8112af3cc9c5 on jcw/mobile-safari-layer-selector into d483bfb436a9014fdb2a199f09039314302f6629 on develop.

jwalgran commented 6 years ago

I force pushed a commit that resolved the build failure.

jwalgran commented 6 years ago

Thanks for the review.