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