@mapmap/maps 0.11.0 → 0.11.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/dist/index.d.ts +11 -0
- package/dist/index.js +32 -0
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/dist/index.d.ts
CHANGED
|
@@ -2871,7 +2871,18 @@ declare class NavigationCamera {
|
|
|
2871
2871
|
private lastRoute;
|
|
2872
2872
|
private recentreTimer;
|
|
2873
2873
|
private destroyed;
|
|
2874
|
+
/** Whether the current free-mode gesture actually moved the map. */
|
|
2875
|
+
private movedWhileFree;
|
|
2874
2876
|
private readonly onInteraction;
|
|
2877
|
+
/** A user-driven move between pointer-down and pointer-up: a real drag. */
|
|
2878
|
+
private readonly onUserMove;
|
|
2879
|
+
/**
|
|
2880
|
+
* Pointer-up. Taking the camera on pointer-down is what lets a drag
|
|
2881
|
+
* start at all, but it would also mean a plain tap — picking a place on
|
|
2882
|
+
* the map, say — silently stopped the chase for the whole idle period.
|
|
2883
|
+
* So a gesture that never actually moved the map hands it straight back.
|
|
2884
|
+
*/
|
|
2885
|
+
private readonly onGestureEnd;
|
|
2875
2886
|
/**
|
|
2876
2887
|
* `false` when the map runs the globe (or vertical-perspective)
|
|
2877
2888
|
* projection, whose camera geometry breaks the low-anchor offset maths
|
package/dist/index.js
CHANGED
|
@@ -4708,7 +4708,11 @@ function firstRow(value) {
|
|
|
4708
4708
|
}
|
|
4709
4709
|
|
|
4710
4710
|
// src/camera.ts
|
|
4711
|
+
var GESTURE_END_EVENTS = ["mouseup", "touchend", "touchcancel"];
|
|
4711
4712
|
var INTERACTION_EVENTS = [
|
|
4713
|
+
"mousedown",
|
|
4714
|
+
"touchstart",
|
|
4715
|
+
"wheel",
|
|
4712
4716
|
"dragstart",
|
|
4713
4717
|
"rotatestart",
|
|
4714
4718
|
"pitchstart",
|
|
@@ -4727,13 +4731,33 @@ var NavigationCamera = class {
|
|
|
4727
4731
|
constructor(map, options = {}) {
|
|
4728
4732
|
this.currentMode = "follow";
|
|
4729
4733
|
this.destroyed = false;
|
|
4734
|
+
/** Whether the current free-mode gesture actually moved the map. */
|
|
4735
|
+
this.movedWhileFree = false;
|
|
4730
4736
|
// Bound once so `off` in destroy() removes exactly what `on` added.
|
|
4731
4737
|
this.onInteraction = (ev) => {
|
|
4732
4738
|
if (!ev?.originalEvent || this.destroyed) return;
|
|
4739
|
+
this.movedWhileFree = false;
|
|
4733
4740
|
this.currentMode = "free";
|
|
4734
4741
|
this.m.stop();
|
|
4735
4742
|
this.scheduleRecentre();
|
|
4736
4743
|
};
|
|
4744
|
+
/** A user-driven move between pointer-down and pointer-up: a real drag. */
|
|
4745
|
+
this.onUserMove = (ev) => {
|
|
4746
|
+
if (!ev?.originalEvent || this.destroyed) return;
|
|
4747
|
+
this.movedWhileFree = true;
|
|
4748
|
+
};
|
|
4749
|
+
/**
|
|
4750
|
+
* Pointer-up. Taking the camera on pointer-down is what lets a drag
|
|
4751
|
+
* start at all, but it would also mean a plain tap — picking a place on
|
|
4752
|
+
* the map, say — silently stopped the chase for the whole idle period.
|
|
4753
|
+
* So a gesture that never actually moved the map hands it straight back.
|
|
4754
|
+
*/
|
|
4755
|
+
this.onGestureEnd = () => {
|
|
4756
|
+
if (this.destroyed || this.currentMode !== "free") return;
|
|
4757
|
+
if (this.movedWhileFree) return;
|
|
4758
|
+
this.clearRecentreTimer();
|
|
4759
|
+
this.resume();
|
|
4760
|
+
};
|
|
4737
4761
|
this.m = map instanceof MapMapMap ? map.map : map;
|
|
4738
4762
|
const design = map instanceof MapMapMap ? map.navDesign?.camera : void 0;
|
|
4739
4763
|
this.pitch = clamp(options.pitch ?? design?.pitch ?? DEFAULT_PITCH, 0, 85);
|
|
@@ -4748,6 +4772,10 @@ var NavigationCamera = class {
|
|
|
4748
4772
|
for (const event of INTERACTION_EVENTS) {
|
|
4749
4773
|
this.m.on(event, this.onInteraction);
|
|
4750
4774
|
}
|
|
4775
|
+
for (const event of GESTURE_END_EVENTS) {
|
|
4776
|
+
this.m.on(event, this.onGestureEnd);
|
|
4777
|
+
}
|
|
4778
|
+
this.m.on("move", this.onUserMove);
|
|
4751
4779
|
}
|
|
4752
4780
|
/**
|
|
4753
4781
|
* `false` when the map runs the globe (or vertical-perspective)
|
|
@@ -4826,6 +4854,10 @@ var NavigationCamera = class {
|
|
|
4826
4854
|
for (const event of INTERACTION_EVENTS) {
|
|
4827
4855
|
this.m.off(event, this.onInteraction);
|
|
4828
4856
|
}
|
|
4857
|
+
for (const event of GESTURE_END_EVENTS) {
|
|
4858
|
+
this.m.off(event, this.onGestureEnd);
|
|
4859
|
+
}
|
|
4860
|
+
this.m.off("move", this.onUserMove);
|
|
4829
4861
|
}
|
|
4830
4862
|
easeToFix(fix, courseDeg, duration) {
|
|
4831
4863
|
this.m.easeTo({
|