Commit Graph

509 Commits

Author SHA1 Message Date
ghybs
d557247d16 style(GridLayerSpec): remove trailing tabs 2018-06-22 12:35:04 +04:00
ghybs
c2d12d0521 test(GridLayer): fix graphical browser zoom out
test on number of pruned tiles during zoom-out in "graphical browsers" (i.e. not PhantomJS) was failing due to incorrect interleaving of rAF and grid.once('load') event listener, not matching the current animation algorithm.
2018-06-22 12:15:22 +04:00
ghybs
5993deb4c8 test(GridLayer): fix graphical browser zoom in
test on number of pruned tiles during zoom-in in "graphical browsers" (i.e. not PhantomJS) was failing due to missing some rAF to let the animation process fully go through and be able to prune the remaining 4 tiles.
2018-06-22 12:09:42 +04:00
ghybs
8c3eaaf3e8 test(Map): set div width for getBoundsZoom parameter inside, Firefox (#6192)
* test(Map): set div width for getBoundsZoom inside

in particular Firefox has a different default width than PhantomJS, making the result different than the expected one. Wider container => can zoom higher to fit the specified bounds.

* docs(Map): getBoundsZoom add padding

3rd argument docstring.
2018-06-20 12:25:05 +02:00
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
ghybs
224bb9372b
Test(MarkerDragSpec): remove commented code (#6049) 2018-02-12 16:39:15 +04:00
Andrew
e3b049cefd Chore(scripts): Remove jake dependency and use NPM scripts instead (#5828)
* run `docs` via npm

* add shebang line to integrity.js, so npm will resolve node binary automatically

* remove unnecessary build-jake npm script

* add test.js script as replacement of Jakefile.js

* remove Jakefile, remove jake from devDependencies

* update docs

* move scripts to separate directory

* change shebang line from nodejs to js

* change shebang line from js to node

* update docs

* use Karma cli instead of custom test script

* add pretest and test-nolint scripts, remove lint scripts from travis.ci

Run linting scripts in pretest script, this way test script will automatically trigger code linting.

Add test-nolint script to have possibility to run tests without triggering pretest script with linting. This is useful when running tests in different browsers and tere's no sense to lint code more than one time

* replace shebang lines with node executable in npm scripts

* remove note about nodejs symlink in CONTRIBUTING.md
2018-02-05 11:15:32 +04:00
Rich Harris
d188cc5ede add pkg.module (#6021)
* add pkg.module version

* get tests to pass

* export noConflict
2018-02-01 10:42:54 -05:00
louMoxy
3e8e76c790 Fix race condition when removing canvas before it has rendered (#6033)
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.
2018-01-29 15:36:50 +01:00
Andrew
c3a6a5b60a Move external dependencies to node_modules (#6028)
* remove sinon from repo and add sinon and karma-sinon devDeps

* remove expect from repo and add karma-expect to devDeps instead

* fix path to sinon and expect in html file for browser testing

* include leaflet-src directly from dist instead of symlink pointing to it
2018-01-29 09:38:05 +04:00
ghybs
510c3e7ba7 Test(ImageOverlay+TileLayer): crossOrigin option add 5th test case (#6027)
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.
2018-01-25 13:46:34 +01:00
Andrew
ad8fc9c36b Fix(GridLayer): Do not fire 'tileload' event if tile src is empty image (#6025)
* do not fire 'load' event if tile src is the empty image (i.e. L.Util.emptyImageUrl)

* add TileLayer setUrl test
2018-01-25 11:08:05 +04:00
ghybs
2dc70945f8 Test(ImageOverlay+TileLayer): crossOrigin option to IMG crossorigin attribute (#6022)
* 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
2018-01-24 15:24:02 +01:00
ghybs
86099a8502
Test(TileLayer): check zoomOffset option is used (#6011)
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.
2018-01-19 06:12:11 +04:00
Michael Siadak
f31e39c1ac Set alt HTML attribute only for img-based Markers (#5979) 2018-01-01 11:30:16 +02:00
Martin Palmér
1d8cc53408 #5921 Remove touch based click tolerance (#5922) 2017-11-17 14:36:23 +01:00
iH8
abc3bf3027 Set _tilezoom to undefined instead of null (#5888)
* Set _tilezoom to undefined instead of null

Set _tilezoom to undefined instead of null

Fix for #5871 https://github.com/Leaflet/Leaflet/issues/5871

* add test
2017-11-13 14:27:52 +01:00
Per Liedman
c5cbbf8174 Clean up and document event propagation properties (#5880)
* 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
2017-10-27 16:18:12 +02:00
Per Liedman
d9846d106b Round pan offset towards zero (#5858)
* Add Point.trunc/_trunc

* Truncate pan offset instead of flooring

Fixes #5821
2017-10-26 15:35:35 +03:00
Andrew
f83b5347f5 skipIfNotTouch instead of overriding Browser.touch (#5869) 2017-10-26 15:34:31 +03:00
Andrew
7e5cbceaa5 add icon popupAnchor option test for nonPhantom browsers (#5865) 2017-10-23 15:29:28 +02:00
Per Liedman
a9742e0d4b Round circle radius in renderer instead of layer
Makes bounds calculation more precise and zoom level independant.
Fixes #4582.
2017-10-20 14:51:48 +02:00
Andrew
b54c2d4adf Fix TileLayer flyTo test (#5843)
* fix TileLayer flyTo test

* fix linter errors
2017-10-16 09:58:25 +03:00
Andrew
d76e5d0372 fix GridLayer flyTo test (#5846) 2017-10-16 09:57:56 +03:00
Fabrizio
d9655a1e9a Change Util.formatNum default to 6 decimals (#5492)
* 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
2017-10-02 18:36:59 +02:00
Andrew
3e3f9e89c4 [LayerGroup] Use eachLayer for iterations over layers (#5809)
* [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
2017-09-30 16:58:10 +03:00
Michael Siadak
2a324b0b94 Add tileerror tests to GridLayer spec (#5805) 2017-09-29 17:04:48 +03:00
Vladimir Agafonkin
88dd22cfe8 upgrade deps, fix indenting (#5743) 2017-08-31 08:58:42 +02:00
Michael Fenwick
0e36b948cd Feature: optionally allow popups to not close on pressing Esc (#5730)
* add test for disabled popup ESC key functionality

* add closeOnEscapeKey default option for popup

* add ESC key condition to prevent map.closePopup

* fix variable indentation

* revert unnecessary mapPopup variable back to map._popup

* add 4 spaces of indentation to variables
2017-08-28 16:11:54 +02:00
Alessandro
5228a62a1c feat(Marker.Drag): autoPan implementation (#5651)
* feat(Marker.Drag): autoPan implementation

* Adjust autoPanSpeed to 10

* Add tests for marker drag
2017-08-09 14:18:13 +02:00
Per Liedman
54ce147f3d Throw if argument to addLayer is not actually a layer (#5689)
Fixes #5225.
2017-08-06 08:36:10 +02:00
Javier Jimenez Shaw
922593addb When a layer is repeated in Control.Layers, behavior is not consistent. (#5672)
* 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
2017-07-31 09:20:40 +02:00
Yohan Boniface
b675753422 Make L.LineUtil._flat public as L.LineUtil.isFlat (#5667)
Also, keep retrocompat for both L.LineUtil._flat and
L.Polyline._flat (<1.1).
2017-07-29 23:47:17 +02:00
Per Liedman
0a6c500e58 Add test for extending L namespace 2017-07-27 11:03:52 +03:00
Vladimir Agafonkin
957f05da23 fix non-extendable objects regression of 1.1.0
Closes #5650 until we figure out a less hacky solution.
2017-07-27 11:03:51 +03:00
jelhan
7a73e1d140 Fix(DomEvent): DomEvent.off should return this (#5601)
Was broken by 14c5f1602c.
2017-07-03 10:47:11 +02:00
ghybs
d6fc47d70e Fix(DivIcon): revert #5517 to avoid appending a single node instead of generating content (#5574)
* 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
2017-06-25 14:11:57 +02:00
Per Liedman
a3ec8047b3 Add className option for ImageOverlay (#5555) 2017-06-22 16:25:15 +02:00
Per Liedman
b23d83f464 Don't turn enter keypress into clicks on map (#5507)
* 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
2017-06-02 11:18:46 +02:00
Matt Grande
1120c46ed9 Add precision parameter to all toGeoJSON functions (#5444)
* 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
2017-05-31 14:06:58 +02:00
MGMsystems
ba7bfb5011 Div icon accept node element as option (#5517)
* 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
2017-05-22 09:57:21 +02:00
Iván Sánchez Ortega
873d4cab31 Handle edge case of empty bounds on _getBoundsCenterZoom (#5157)
* Handle edge case of empty bounds on _getBoundsCenterZoom

* Unit test for map._getBoundsCenterZoom
2017-05-11 22:33:46 +02:00
ghybs
f677f9c6d2 Feat(Bounds): add new methods for 2 missing corners (#5488)
* 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.
2017-05-11 22:24:15 +02:00
Iván Sánchez Ortega
7e1740ecdf Better sanity checks for avoiding loading infinite tiles (#5479)
* Sanity check to prevent loading tiles when bounds are `Infinity`

* Make linter happy

* Better sanity checks for avoiding loading infinite tiles

* typo
2017-04-25 15:00:47 +02:00
Dave Leaver
27263b7afa Control.Layers: Only add layer events to layers when we are on the map. Fixes #5421 (#5422) 2017-03-28 23:10:29 +02:00
Tom Salisbury
96cfdd3a3d Added z-index support to ImageOverlay (#5418) 2017-03-28 10:54:24 +02:00
Tom Salisbury
8278ed393d Added error event to ImageOverlay layer and added tests for the new (#5416)
event and existing error handling. Also added missing
documentation for the load event.
2017-03-28 08:54:26 +02:00
Per Liedman
c18ac11efb Include L.Mixin.Events again; add deprecation notice (#5365)
Close #5358
2017-03-07 09:53:24 +01:00
Lewis Christie
0ed260c847 fix invalid geoJSON produced by nested LayerGroups (#5359) 2017-03-02 13:21:56 +01:00
ghybs
9e4f79d1e5 Fix(#5328): Layers Control can now become scrollable even if collapsed: false (#5348)
* 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)
2017-02-21 14:33:01 +01:00