* 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).
Fixes#6030: Cancel animation frame request before removing the map.
This fixes the bug where the the delayed call to _redraw is trying to get the drawing context which has already been destroyed.
when passing `crossOrigin: ''` (empty string) option, the `crossorigin` attribute should also be set an empty string value (valid keyword, with same effect as `"anonymous"` value). Need to add this test, because in JavaScript the empty string is a falsy value that could have been caught as `false` and led to no `crossorigin` attribute set.
* Test(ImageOverlay): crossOrigin option to IMG crossorigin attribute
typical values: false (default), true => '', <string> => <string>
now that a string value can be passed to this option.
* Test(TileLayer): crossOrigin option to IMG crossorigin attribute
typical values: false (default), true => '', <string> => <string>
now that a string value can be passed to this option.
* Style(TileLayerSpec): remove commented code
* Style(TileLayerSpec): remove more commented code
following issue #6004 (fixed by PR #6006).
Added 2 dedicated tests.
Unfortunately I could not add a test for detectRetina option that easily, because since the move to Rollup, Browser values became internal variables, and overriding them later on does not have any effect on Leaflet internal references… Not sure how to workaround this for the sake of testing.
* Add sourceTarget and propagatedFrom to events
Also documents events' target, sourceTarget, propagatedFrom
and layer properties.
Fixes#4510.
* Use propagatedFrom, which is equivalent of the original code
* propagetedFrom -> propagatedFrom
* Util.formatNum default to 6
Changed Util.formaNum default to 6 decimails.
Solved 0 decimals bug.
Added tests.
Can be useful for PR #5444
* Changed documentation
Changed documentation to 6 instead of 5
* [LayerGroup] use eachLayer method instead of for...in
* [LayerGroup] use eachLayer method in getLayers method
* [LayerGroup] use eachLayer method in onAdd & onRemove methods
* [LayerGroup] invoke method fix
- use `eachLayer` method instead of for...in
- add unit test for `invoke` method
* revert invoke method change
* Check if the map has a layer after layers removal, not before.
* fix wrong layer to add
* do symetric code with removedLayers and addedLayers
* add unit test for repeated layers
* Docs(Marker): explain checks for re-using icon element
when the marker is modified with an icon of the same type (i.e. an image icon with an image icon, or a DivIcon with a DivIcon), or checks for NOT re-using the icon element when modifying with an icon of a different type (i.e. an image icon with a DivIcon, or the reverse).
* Revert "Div icon accept node element as option (#5517)"
This reverts commit ba7bfb5011.
Conflicts:
spec/suites/layer/marker/MarkerSpec.js
* Don't turn enter keypress into clicks on map
But still preserve functionality to open marker's popup through
enter keypress when focused.
Fixes#5499.
* Clean code
Thanks @egoroof
* Change name of keypress handler to _onKeyPress
* Add unit test
* Add precision parameter to all toGeoJSON functions
* Replace usage of toPrecision with Utils.formatNum
* Always default to six decimal places
* Fix docs
* Allow precision of 0
* Added option to allow DOM elements inside a DIV icon
* Removed white line
* Adapted so that the dom element can be passed with the html option
* Update DivIcon.js
Changed documentation to state HTMLElement
* Feat(Bounds): add getTopLeft & getBottomRight methods
as suggested in #5475, for consistency with `LatLngBounds` methods which already provide methods for the 4 possible corners.
Also include the docstrings.
* Docs(Bounds): add comments to identify corners
in BoundsSpec.
* Test(Bounds): add tests for existing corner methods
namely getBottomLeft and getTopRight.
Checked that expecting different values make the tests fail.
* Test(Bounds): add spec for 2 new corner methods
namely getTopLeft and getBottomRight.
Closes#5475 together with previous PR #5487.
* Refactor(Bounds): return this.min(max) instead of new Point
as TopLeft corner is tha same as this.min (BottomRight same as this.max).
* Docs(Bounds): add links to this.min(max)
to make it clearer that these methods are just shorthands to already available properties.
Furthermore, it implies that they output those properties directly, making a clue for the app developer that if he/she wants to modify them, they should be cloned before doing so in order to prevent unintentional behaviour.
* Fix(#5328): Layers Control scrollable even if collapsed: false
the `expand()` method was called only when expanding the Layers Control through user action.
In the case of option `collapsed: false`, no event listener is attached (no user action expected to expand), therefore the control height is no longer adjusted compared to map container's height, whereas the only time it is done is at initialization, when the control is not yet inserted into the DOM, hence it does not have an actual height to check against.
Therefore added a hook on `addTo()` in order to run `expand()` AFTER the control has been insterted into the DOM.
The same issue happens when later adding more base layers / overlays to the Layers Control: it not collapsed, we should run again the height check (e.g. through the `expand()` method) to make sure we make it scrollable if necessary.
Therefore called `expand()` after each `_addLayer()`.
Actually checking first if the control is on map and if option `collapsed: false` in order to prevent calling `expand()` for nothing.
* Test(ControlLayers): 2 tests for collapsed: false being scrollable
(for issue #5328).
CAUTION: unlike most other tests, had to actually insert the map container into the DOM (i.e. `document.body`) for these tests to be useful, otherwise the height remains at 0.
This may lead to memory leak and tests hanging if done on too many tests (see Leaflet.markercluster tests issue, e.g. https://github.com/Leaflet/Leaflet.markercluster/pull/577)
* Add some tests for #5293
* Fix enabling marker dragging while markers aren't on the map by removing the dragging object when not on the map.
This is a change of behavior (.dragging is only defined when a marker is on the map).
* Docs for dragging change