leaflet-rotate 0.4.0 → 0.5.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (39) hide show
  1. package/README.md +85 -5
  2. package/dist/leaflet-rotate-src.js +1325 -254
  3. package/dist/leaflet-rotate-src.js.map +4 -4
  4. package/dist/leaflet-rotate.js +1 -1
  5. package/dist/leaflet-rotate.js.map +4 -4
  6. package/lib/debug.js +62 -88
  7. package/lib/debug.min.js +16 -1
  8. package/misc/leaflet-heat-rotate.js +7 -0
  9. package/package.json +1 -1
  10. package/src/control/Rotate.js +160 -103
  11. package/src/dom/DomUtil.js +23 -12
  12. package/src/dom/Draggable.js +5 -0
  13. package/src/geo/LatLngBounds.js +5 -0
  14. package/src/geometry/Bounds.js +5 -0
  15. package/src/geometry/Point.js +17 -3
  16. package/src/index.js +4 -1
  17. package/src/layer/DivOverlay.js +34 -5
  18. package/src/layer/Popup.js +14 -3
  19. package/src/layer/Tooltip.js +16 -0
  20. package/src/layer/marker/Icon.js +12 -0
  21. package/src/layer/marker/Marker.js +86 -7
  22. package/src/layer/tile/GridLayer.js +38 -3
  23. package/src/layer/vector/Renderer.js +88 -34
  24. package/src/map/Map.js +578 -116
  25. package/src/map/handler/CompassBearing.js +34 -1
  26. package/src/map/handler/ContainerMutation.js +18 -1
  27. package/src/map/handler/ShiftKeyRotate.js +204 -13
  28. package/src/map/handler/TouchGestures.js +108 -10
  29. package/src/map/handler/TouchPitch.js +53 -0
  30. package/src/map/handler/TouchRotate.js +18 -1
  31. package/src/map/handler/TouchZoom.js +21 -1
  32. package/test/features/example.feature +8 -4
  33. package/test/features/gestures.feature +4 -0
  34. package/test/features/rotation.feature +60 -0
  35. package/test/index.html +342 -186
  36. package/test/steps/bearing.steps.js +535 -0
  37. package/test/steps/example.steps.js +56 -29
  38. package/test/steps/gestures.steps.js +55 -0
  39. package/test/support/hooks.js +4 -16
@@ -1,7 +1,10 @@
1
1
  /**
2
- * Rotates the map on two-finger (touch devices).
2
+ * Enables two-finger rotation through the shared touch-gesture handler.
3
3
  *
4
4
  * @typedef L.Map.TouchRotate
5
+ * @property {boolean} [touchRotate=false] Enable two-finger map rotation.
6
+ *
7
+ * @since leaflet-rotate (v0.1.0)
5
8
  */
6
9
 
7
10
  L.Map.mergeOptions({
@@ -10,6 +13,8 @@ L.Map.mergeOptions({
10
13
  * Whether the map can be rotated with a two-finger rotation gesture
11
14
  *
12
15
  * @type {Boolean}
16
+ *
17
+ * @since leaflet-rotate (v0.1.0)
13
18
  */
14
19
  touchRotate: false,
15
20
 
@@ -17,11 +22,21 @@ L.Map.mergeOptions({
17
22
 
18
23
  L.Map.TouchRotate = L.Handler.extend({
19
24
 
25
+ /**
26
+ * Enable rotation handling in the map's shared touch gesture handler.
27
+ *
28
+ * @since leaflet-rotate (v0.1.0)
29
+ */
20
30
  addHooks() {
21
31
  this._map.touchGestures.enable();
22
32
  this._map.touchGestures.rotate = true;
23
33
  },
24
34
 
35
+ /**
36
+ * Disable rotation handling without affecting pinch zoom.
37
+ *
38
+ * @since leaflet-rotate (v0.1.0)
39
+ */
25
40
  removeHooks() {
26
41
  this._map.touchGestures.rotate = false;
27
42
  },
@@ -32,5 +47,7 @@ L.Map.TouchRotate = L.Handler.extend({
32
47
  * Add Touch Rotate handler (disabled unless `touchGestures` is set).
33
48
  *
34
49
  * @property {L.Map.TouchGestures} touchGestures
50
+ *
51
+ * @since leaflet-rotate (v0.1.0)
35
52
  */
36
53
  L.Map.addInitHook('addHandler', 'touchRotate', L.Map.TouchRotate);
@@ -1,9 +1,13 @@
1
1
  /**
2
- * Adds pinch zoom rotation on mobile browsers
2
+ * Adds pinch zoom support through the shared touch-gesture handler.
3
3
  *
4
4
  * @see https://github.com/Leaflet/Leaflet/blob/v1.9.3/src/map/handler/Map.TouchZoom.js
5
5
  *
6
6
  * @external L.Map.TouchZoom
7
+ * @property {boolean|string} [touchZoom=L.Browser.touch] Enable pinch zoom; `'center'` zooms around the view center.
8
+ * @property {boolean} [bounceAtZoomLimits=false] Allow pinch zoom to exceed zoom limits before settling.
9
+ *
10
+ * @since leaflet-rotate (v0.1.0)
7
11
  */
8
12
 
9
13
  L.Map.mergeOptions({
@@ -16,6 +20,8 @@ L.Map.mergeOptions({
16
20
  * for touch-capable web browsers.
17
21
  *
18
22
  * @type {(Boolean|String)}
23
+ *
24
+ * @since leaflet-rotate (v0.1.0)
19
25
  */
20
26
  touchZoom: L.Browser.touch,
21
27
 
@@ -27,6 +33,8 @@ L.Map.mergeOptions({
27
33
  * when pinch-zooming.
28
34
  *
29
35
  * @type {Boolean}
36
+ *
37
+ * @since leaflet-rotate (v0.1.0)
30
38
  */
31
39
  bounceAtZoomLimits: false,
32
40
 
@@ -34,12 +42,22 @@ L.Map.mergeOptions({
34
42
 
35
43
  L.Map.TouchZoom = L.Handler.extend({
36
44
 
45
+ /**
46
+ * Enable pinch zoom handling and mark the shared touch handler as active.
47
+ *
48
+ * @since leaflet-rotate (v0.1.0)
49
+ */
37
50
  addHooks() {
38
51
  this._map._container.classList.add('leaflet-touch-zoom');
39
52
  this._map.touchGestures.enable();
40
53
  this._map.touchGestures.zoom = true;
41
54
  },
42
55
 
56
+ /**
57
+ * Disable pinch zoom handling while preserving touch rotation state.
58
+ *
59
+ * @since leaflet-rotate (v0.1.0)
60
+ */
43
61
  removeHooks() {
44
62
  this._map._container.classList.remove('leaflet-touch-zoom');
45
63
  this._map.touchGestures.zoom = false;
@@ -51,5 +69,7 @@ L.Map.TouchZoom = L.Handler.extend({
51
69
  * Add Touch Zoom handler (disabled unless `L.Browser.touch` is set).
52
70
  *
53
71
  * @property {L.Map.TouchGestures} touchGestures
72
+ *
73
+ * @since leaflet-rotate (v0.1.0)
54
74
  */
55
75
  L.Map.addInitHook('addHandler', 'touchZoom', L.Map.TouchZoom);
@@ -13,13 +13,17 @@ Feature: Rotating a Leaflet map
13
13
  Then the default rotate control visibility follows the bearing
14
14
 
15
15
  @issue-13
16
- Scenario: Dragging the rotate control changes the map bearing
16
+ Scenario: Dragging the rotate control changes the map bearing and pitch
17
17
  When I drag the rotate control
18
- Then the map bearing follows the control drag
18
+ Then the map bearing and pitch follow the control drag
19
+
20
+ Scenario: Clicking the rotate control resets bearing and pitch
21
+ When I click the rotate control on a rotated and pitched map
22
+ Then the map animates back to north and zero pitch
19
23
 
20
24
  @issue-44
21
- Scenario: The compass control requests device-orientation permission
22
- When I activate compass mode on a permission-based device
25
+ Scenario: Enabling compass bearing requests device-orientation permission
26
+ When I enable compass bearing on a permission-based device
23
27
  Then device-orientation permission is requested
24
28
 
25
29
  @issue-7
@@ -7,6 +7,10 @@ Feature: Rotating a Leaflet map
7
7
  When I move a two-finger pinch gesture
8
8
  Then the zoom transition ends before the gesture ends
9
9
 
10
+ Scenario: Two fingers dragged vertically change the pitch, pinching does not
11
+ When I drag two fingers vertically and then pinch with touch pitch enabled
12
+ Then only the vertical two-finger drag changes the pitch
13
+
10
14
  @issue-43
11
15
  Scenario: Vector paths follow a rotated two-finger gesture
12
16
  When I rotate and zoom two fingers over a vector path
@@ -21,6 +21,36 @@ Feature: Rotating a Leaflet map
21
21
  When I animate the bearing to 90 degrees
22
22
  Then the bearing reaches 90 degrees gradually
23
23
 
24
+ @issue-72
25
+ Scenario: Pitch projects and reverses map coordinates
26
+ When I set the map pitch to 45 degrees
27
+ Then map coordinates stay consistent with the pitched view
28
+
29
+ @issue-72
30
+ Scenario: Ctrl-drag changes pitch and bearing without panning
31
+ When I change pitch and bearing with Ctrl-drag
32
+ Then pitch and bearing change without moving the map pane
33
+
34
+ @issue-72
35
+ Scenario: Pitched vector layers stay aligned while panning
36
+ When I drag the pitched map
37
+ Then vector layers stay aligned with their map coordinates
38
+
39
+ @issue-72
40
+ Scenario: Vector layers stay aligned after off-center zoom and rotation
41
+ When I zoom off-center then rotate the map
42
+ Then vector layers stay aligned with their map coordinates
43
+
44
+ @issue-72
45
+ Scenario: Ctrl-drag after panning keeps the map center stable
46
+ When I pan the map then Ctrl-drag
47
+ Then the map center stays stable during Ctrl-drag
48
+
49
+ @issue-72
50
+ Scenario: Ctrl-drag cancels a pending wheel zoom
51
+ When I Ctrl-drag while a wheel zoom is pending
52
+ Then the pending wheel zoom does not move the map
53
+
24
54
  @issue-25
25
55
  Scenario: Fit bounds zoom is stable
26
56
  When I fit the same bounds twice
@@ -34,3 +64,33 @@ Feature: Rotating a Leaflet map
34
64
  @issue-34
35
65
  Scenario: Draggable marker listeners are not duplicated
36
66
  Then the draggable marker has one drag listener and one drag-end listener
67
+
68
+ @issue-73
69
+ Scenario: Vector layers do not jump when zooming from a low level
70
+ When I animate a zoom from a low level on a rotated map
71
+ Then vector layers do not jump at the end of the zoom animation
72
+
73
+ @issue-73
74
+ Scenario: Wheel zoom keeps the cursor point on a pitched map
75
+ When I zoom around an off-center point on a pitched map
76
+ Then the point under the cursor stays in place
77
+
78
+ @issue-73
79
+ Scenario: Right-drag rotates around the map center
80
+ When I right-drag horizontally below the map center
81
+ Then the map rotates counterclockwise without opening the context menu
82
+
83
+ @issue-73
84
+ Scenario: Right-button press suppresses the context menu before movement
85
+ When a context menu event fires immediately on right-button press
86
+ Then the early context menu is suppressed
87
+
88
+ @issue-73
89
+ Scenario: High pitch keeps tile loading bounded
90
+ When I look at a high zoom map with a high pitch
91
+ Then tile loading stays bounded and covers the visible map
92
+
93
+ @issue-73
94
+ Scenario: Tiles stay aligned after panning and changing pitch
95
+ When I pan, zoom and change the pitch of a rotated map
96
+ Then the map is centered and the tiles stay aligned with the map coordinates