Leaflet/debug/map
ghybs fe9e0f2333
Fix(Draggable): compensate for container CSS scale (#6055)
* Test(MapDragSpec): add mouse drag with CSS scaled container

This test is failing as of this commit.

* Fix(Draggable): measure drag compensating for CSS scale

so that the computed offset (i.e. user drag length) is divided by the CSS scale applied on the `_element`'s container. Later on when `Draggable` updates the `_element`'s position, the latter is affected by the CSS scale by the browser.
Added a `getSizedParentNode` function in `DomUtil` in order to automatically retrieve the closest parent node in the DOM hierarchy tree that has a non null size (so that we can compute the scale in `DomEvent.getMousePosition`), without having to specify the parent node explicitly (which is ugly).

* Fix(getMousePosition): getBoundingClientRect is in page scale

therefore it must also be divided by the container scale in order to compute the relative position of the event in the scaled container.

* Test(MarkerDragSpec): add drag with CSS scaled container

this should pass automatically at this commit, thanks to the previous modification of Draggable.

* Debug(map-scaled): add draggable marker

as well as another CSS scaled wrapper, plus some border and padding, and debugging console logs, to make sure the computations of `getMousePosition` are correct (correctly removing the border width, and compensating for CSS scale).

* Docs(getMousePosition): explicitly exclude border

* Docs(DomUtil): add return value of getSizedParentNode

was missing in docstring.

* Feat(DomUtil): add getScale function

so that it can be used by DomEvent.getMousePosition and Draggable.

* Refactor(Draggable): cache container scale

to avoid triggering browser reflow continuously during _onMove, but only on drag start (_onDown).
By compensating for the scale within Draggable instead of delegating to DomEvent.getMousePosition, it also becomes possible to check first for the clickTolerance, so that we prevents user's small movement based on screen, irrespective of rendered scale.

* Test(Map+MarkerDrag): remove scale on initial movement

that is intended to overcome Draggable clickTolerance, since now it is based on screen pixels, irrespective of applied CSS scale on the map.
Thanks to the tolerance in the expected final position, this has no effect on the result of the test, even though the overall drag is now slightly shorter.

* Refactor(DomEvent): use DomUtil.getScale in getMousePosition

to factorize scale computation (also used within Draggable).
2018-03-16 19:46:44 +04:00
..
canvas.html Fix debug examples after rollup (#5417) 2017-03-28 08:40:48 +02:00
control-layers.html Use https everywhere for OSM links (#6082) 2018-03-12 08:46:20 +01:00
controls.html Use https everywhere for OSM links (#6082) 2018-03-12 08:46:20 +01:00
geolocation.html Use https everywhere for OSM links (#6082) 2018-03-12 08:46:20 +01:00
grid.html Fix debug examples after rollup (#5417) 2017-03-28 08:40:48 +02:00
iframe.html Add iframe debug html 2013-06-24 16:35:00 -04:00
image-overlay.html Use https everywhere for OSM links (#6082) 2018-03-12 08:46:20 +01:00
layer_remove_add.html Use https everywhere for OSM links (#6082) 2018-03-12 08:46:20 +01:00
map-mobile.html Use https everywhere for OSM links (#6082) 2018-03-12 08:46:20 +01:00
map-popup.html Use https everywhere for OSM links (#6082) 2018-03-12 08:46:20 +01:00
map-scaled.html Fix(Draggable): compensate for container CSS scale (#6055) 2018-03-16 19:46:44 +04:00
map.html Use https everywhere for OSM links (#6082) 2018-03-12 08:46:20 +01:00
marker-autopan.html Use https everywhere for OSM links (#6082) 2018-03-12 08:46:20 +01:00
markers.html Use https everywhere for OSM links (#6082) 2018-03-12 08:46:20 +01:00
max-bounds-bouncy.html Use https everywhere for OSM links (#6082) 2018-03-12 08:46:20 +01:00
max-bounds-infinite.html Use https everywhere for OSM links (#6082) 2018-03-12 08:46:20 +01:00
max-bounds.html Use https everywhere for OSM links (#6082) 2018-03-12 08:46:20 +01:00
opacity.html Use https everywhere for OSM links (#6082) 2018-03-12 08:46:20 +01:00
popup.html Use https everywhere for OSM links (#6082) 2018-03-12 08:46:20 +01:00
rollup.html Use https everywhere for OSM links (#6082) 2018-03-12 08:46:20 +01:00
scroll.html Use https everywhere for OSM links (#6082) 2018-03-12 08:46:20 +01:00
simple-proj.html Fix debug examples after rollup (#5417) 2017-03-28 08:40:48 +02:00
tile-debug.html Fix debug examples after rollup (#5417) 2017-03-28 08:40:48 +02:00
tile-opacity.html Fix debug examples after rollup (#5417) 2017-03-28 08:40:48 +02:00
tooltip.html Use https everywhere for OSM links (#6082) 2018-03-12 08:46:20 +01:00
videooverlay.html Remove reference to deps.js in L.VideoOverlay debug example 2017-07-14 21:46:42 -04:00
wms-marble.html Fix debug examples after rollup (#5417) 2017-03-28 08:40:48 +02:00
wms.html Use https everywhere for OSM links (#6082) 2018-03-12 08:46:20 +01:00
zoom-delta.html Use https everywhere for OSM links (#6082) 2018-03-12 08:46:20 +01:00
zoom-remain-centered.html Use https everywhere for OSM links (#6082) 2018-03-12 08:46:20 +01:00
zoomlevels.html Use https everywhere for OSM links (#6082) 2018-03-12 08:46:20 +01:00
zoompan.html Use https everywhere for OSM links (#6082) 2018-03-12 08:46:20 +01:00