mudlet-map-renderer 1.1.0 → 1.2.0
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/camera/Camera.d.ts +12 -0
- package/dist/index.mjs +19 -5
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/camera/Camera.d.ts
CHANGED
|
@@ -31,6 +31,8 @@ export declare class Camera extends TypedEventEmitter<CameraEventMap> {
|
|
|
31
31
|
private dragStart;
|
|
32
32
|
private positionAtDragStart;
|
|
33
33
|
private animationId?;
|
|
34
|
+
private batchDepth;
|
|
35
|
+
private batchDirty;
|
|
34
36
|
constructor(width: number, height: number);
|
|
35
37
|
getScale(): number;
|
|
36
38
|
setZoom(zoom: number): boolean;
|
|
@@ -102,5 +104,15 @@ export declare class Camera extends TypedEventEmitter<CameraEventMap> {
|
|
|
102
104
|
private animate;
|
|
103
105
|
cancelAnimation(): void;
|
|
104
106
|
isAnimating(): boolean;
|
|
107
|
+
/**
|
|
108
|
+
* Run a function that performs multiple camera mutations and emit only one
|
|
109
|
+
* `change` event at the end (if anything actually mutated). Use this when a
|
|
110
|
+
* single logical operation needs to touch more than one camera field —
|
|
111
|
+
* resize-then-recenter, for example — so subscribers never observe a
|
|
112
|
+
* transient inconsistent state (new size with stale position).
|
|
113
|
+
*
|
|
114
|
+
* Nested batches are supported: only the outermost batch emits.
|
|
115
|
+
*/
|
|
116
|
+
batch<T>(fn: () => T): T;
|
|
105
117
|
private notify;
|
|
106
118
|
}
|
package/dist/index.mjs
CHANGED
|
@@ -400,7 +400,7 @@ var D = class e extends S {
|
|
|
400
400
|
}, this.positionAtDragStart = {
|
|
401
401
|
x: 0,
|
|
402
402
|
y: 0
|
|
403
|
-
}, this.width = e, this.height = t;
|
|
403
|
+
}, this.batchDepth = 0, this.batchDirty = !1, this.width = e, this.height = t;
|
|
404
404
|
}
|
|
405
405
|
getScale() {
|
|
406
406
|
return 75 * this.zoom;
|
|
@@ -551,7 +551,19 @@ var D = class e extends S {
|
|
|
551
551
|
isAnimating() {
|
|
552
552
|
return this.animationId !== void 0;
|
|
553
553
|
}
|
|
554
|
+
batch(e) {
|
|
555
|
+
this.batchDepth++;
|
|
556
|
+
try {
|
|
557
|
+
return e();
|
|
558
|
+
} finally {
|
|
559
|
+
this.batchDepth--, this.batchDepth === 0 && this.batchDirty && (this.batchDirty = !1, this.emit("change", void 0));
|
|
560
|
+
}
|
|
561
|
+
}
|
|
554
562
|
notify() {
|
|
563
|
+
if (this.batchDepth > 0) {
|
|
564
|
+
this.batchDirty = !0;
|
|
565
|
+
return;
|
|
566
|
+
}
|
|
555
567
|
this.emit("change", void 0);
|
|
556
568
|
}
|
|
557
569
|
}, O = (e, t) => ({
|
|
@@ -2255,10 +2267,12 @@ var ze = {
|
|
|
2255
2267
|
}
|
|
2256
2268
|
initViewportEvents() {
|
|
2257
2269
|
let e = this.container, t = this.camera, n = 1.1, r = () => {
|
|
2258
|
-
|
|
2259
|
-
|
|
2260
|
-
|
|
2261
|
-
|
|
2270
|
+
t.batch(() => {
|
|
2271
|
+
if (t.setSize(e.clientWidth, e.clientHeight), t.centerOnResize && this.state.positionRoomId) {
|
|
2272
|
+
let e = this.state.mapReader.getRoom(this.state.positionRoomId);
|
|
2273
|
+
e && t.panToMapPoint(e.x, e.y);
|
|
2274
|
+
}
|
|
2275
|
+
});
|
|
2262
2276
|
};
|
|
2263
2277
|
typeof window < "u" && this.listen(window, "resize", r), this.listen(e, "resize", r);
|
|
2264
2278
|
let i = !1, a;
|