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.
- package/README.md +85 -5
- package/dist/leaflet-rotate-src.js +1325 -254
- package/dist/leaflet-rotate-src.js.map +4 -4
- package/dist/leaflet-rotate.js +1 -1
- package/dist/leaflet-rotate.js.map +4 -4
- package/lib/debug.js +62 -88
- package/lib/debug.min.js +16 -1
- package/misc/leaflet-heat-rotate.js +7 -0
- package/package.json +1 -1
- package/src/control/Rotate.js +160 -103
- package/src/dom/DomUtil.js +23 -12
- package/src/dom/Draggable.js +5 -0
- package/src/geo/LatLngBounds.js +5 -0
- package/src/geometry/Bounds.js +5 -0
- package/src/geometry/Point.js +17 -3
- package/src/index.js +4 -1
- package/src/layer/DivOverlay.js +34 -5
- package/src/layer/Popup.js +14 -3
- package/src/layer/Tooltip.js +16 -0
- package/src/layer/marker/Icon.js +12 -0
- package/src/layer/marker/Marker.js +86 -7
- package/src/layer/tile/GridLayer.js +38 -3
- package/src/layer/vector/Renderer.js +88 -34
- package/src/map/Map.js +578 -116
- package/src/map/handler/CompassBearing.js +34 -1
- package/src/map/handler/ContainerMutation.js +18 -1
- package/src/map/handler/ShiftKeyRotate.js +204 -13
- package/src/map/handler/TouchGestures.js +108 -10
- package/src/map/handler/TouchPitch.js +53 -0
- package/src/map/handler/TouchRotate.js +18 -1
- package/src/map/handler/TouchZoom.js +21 -1
- package/test/features/example.feature +8 -4
- package/test/features/gestures.feature +4 -0
- package/test/features/rotation.feature +60 -0
- package/test/index.html +342 -186
- package/test/steps/bearing.steps.js +535 -0
- package/test/steps/example.steps.js +56 -29
- package/test/steps/gestures.steps.js +55 -0
- package/test/support/hooks.js +4 -16
|
@@ -53,6 +53,61 @@ When('I move a two-finger pinch gesture', async function () {
|
|
|
53
53
|
});
|
|
54
54
|
});
|
|
55
55
|
|
|
56
|
+
When('I drag two fingers vertically and then pinch with touch pitch enabled', async function () {
|
|
57
|
+
this.touchPitch = await this.page.evaluate(() => {
|
|
58
|
+
map.setView([55, 10], 6, { animate: false });
|
|
59
|
+
map.setPitch(0);
|
|
60
|
+
map.setBearing(20);
|
|
61
|
+
map.touchPitch.enable();
|
|
62
|
+
const container = map.getContainer();
|
|
63
|
+
const rect = container.getBoundingClientRect();
|
|
64
|
+
const centerX = rect.left + rect.width / 2;
|
|
65
|
+
const centerY = rect.top + rect.height / 2;
|
|
66
|
+
const touches = (x1, y1, x2, y2) => [
|
|
67
|
+
new Touch({ identifier: 1, target: container, clientX: centerX + x1, clientY: centerY + y1 }),
|
|
68
|
+
new Touch({ identifier: 2, target: container, clientX: centerX + x2, clientY: centerY + y2 }),
|
|
69
|
+
];
|
|
70
|
+
const dispatch = (target, type, activeTouches, changedTouches = activeTouches) => {
|
|
71
|
+
target.dispatchEvent(new TouchEvent(type, {
|
|
72
|
+
bubbles: true,
|
|
73
|
+
cancelable: true,
|
|
74
|
+
touches: activeTouches,
|
|
75
|
+
targetTouches: activeTouches,
|
|
76
|
+
changedTouches,
|
|
77
|
+
}));
|
|
78
|
+
};
|
|
79
|
+
const state = () => ({ pitch: map.getPitch(), bearing: map.getBearing(), zoom: map.getZoom() });
|
|
80
|
+
|
|
81
|
+
// both fingers up by 60px: pitch +30°
|
|
82
|
+
dispatch(container, 'touchstart', touches(-40, 0, 40, 0));
|
|
83
|
+
for (let dy = -10; dy >= -60; dy -= 10) {
|
|
84
|
+
dispatch(document, 'touchmove', touches(-40, dy, 40, dy));
|
|
85
|
+
}
|
|
86
|
+
dispatch(document, 'touchend', [], touches(-40, -60, 40, -60));
|
|
87
|
+
const afterPitch = state();
|
|
88
|
+
|
|
89
|
+
// fingers spreading apart vertically: pinch, pitch unchanged
|
|
90
|
+
dispatch(container, 'touchstart', touches(-40, 0, 40, 0));
|
|
91
|
+
for (let d = 10; d <= 40; d += 10) {
|
|
92
|
+
dispatch(document, 'touchmove', touches(-40 - d, -d, 40 + d, d));
|
|
93
|
+
}
|
|
94
|
+
dispatch(document, 'touchend', [], touches(-80, -40, 80, 40));
|
|
95
|
+
const afterPinch = state();
|
|
96
|
+
|
|
97
|
+
map.touchPitch.disable();
|
|
98
|
+
map.setPitch(0);
|
|
99
|
+
return { afterPitch, afterPinch };
|
|
100
|
+
});
|
|
101
|
+
});
|
|
102
|
+
|
|
103
|
+
Then('only the vertical two-finger drag changes the pitch', function () {
|
|
104
|
+
const { afterPitch, afterPinch } = this.touchPitch;
|
|
105
|
+
assert.ok(Math.abs(afterPitch.pitch - 30) < 1e-6, JSON.stringify(this.touchPitch));
|
|
106
|
+
assert.ok(Math.abs(afterPitch.bearing - 20) < 1e-6, JSON.stringify(this.touchPitch));
|
|
107
|
+
assert.equal(afterPitch.zoom, 6);
|
|
108
|
+
assert.ok(Math.abs(afterPinch.pitch - 30) < 1e-6, JSON.stringify(this.touchPitch));
|
|
109
|
+
});
|
|
110
|
+
|
|
56
111
|
When('I drag a constrained marker on a rotated map', async function () {
|
|
57
112
|
await this.page.evaluate(() => {
|
|
58
113
|
map.options.zoomAnimation = false;
|
package/test/support/hooks.js
CHANGED
|
@@ -33,22 +33,10 @@ Before(async function () {
|
|
|
33
33
|
.replace(/\bconst (map|esri|osm|layers|markers|path|circle|polygon|rectangle) =/g, 'const $1 = window.$1 =');
|
|
34
34
|
if (version === '2') {
|
|
35
35
|
body = body
|
|
36
|
-
.replace(
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
await new Promise((resolve, reject) => {
|
|
41
|
-
const script = document.createElement('script');
|
|
42
|
-
script.src = src;
|
|
43
|
-
script.onload = resolve;
|
|
44
|
-
script.onerror = () => reject(new Error(\`Could not load \${src}\`));
|
|
45
|
-
document.head.appendChild(script);
|
|
46
|
-
});
|
|
47
|
-
}
|
|
48
|
-
});
|
|
49
|
-
</script>`)
|
|
50
|
-
.replace(/<script src="\.\.\/(?:dist|misc|lib)\/[^"]+"><\/script>/g, '')
|
|
51
|
-
.replace(/<script>\s*(const esri[\s\S]*?L\.Rotate\.debug\(map\);\s*)<\/script>/, '<script>globalThis.__leafletLoading.then(() => {$1});</script>')
|
|
36
|
+
.replace(
|
|
37
|
+
'<script src="https://unpkg.com/leaflet@1.9/dist/leaflet-src.js"></script>',
|
|
38
|
+
'<script src="https://unpkg.com/leaflet@2.0.0-alpha.1/dist/leaflet-global-src.js"></script><script>globalThis.L = globalThis.leaflet;</script>'
|
|
39
|
+
)
|
|
52
40
|
.replace('https://unpkg.com/leaflet@1.9/dist/leaflet.css', 'https://unpkg.com/leaflet@2.0.0-alpha.1/dist/leaflet.css');
|
|
53
41
|
}
|
|
54
42
|
await route.fulfill({ response, body, headers: response.headers() });
|