@tldraw/editor 5.2.0-canary.ff23978d50f6 → 5.2.0-next.5d769d321393
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-cjs/index.js +1 -1
- package/dist-cjs/lib/editor/Editor.js +11 -10
- package/dist-cjs/lib/editor/Editor.js.map +3 -3
- package/dist-cjs/version.js +3 -3
- package/dist-cjs/version.js.map +1 -1
- package/dist-esm/index.mjs +1 -1
- package/dist-esm/lib/editor/Editor.mjs +11 -10
- package/dist-esm/lib/editor/Editor.mjs.map +3 -3
- package/dist-esm/version.mjs +3 -3
- package/dist-esm/version.mjs.map +1 -1
- package/package.json +7 -7
- package/src/lib/editor/Editor.ts +20 -14
- package/src/version.ts +3 -3
package/dist-cjs/index.js
CHANGED
|
@@ -380,7 +380,7 @@ var import_uniq = require("./lib/utils/uniq");
|
|
|
380
380
|
var import_defaultThemes2 = require("./lib/editor/managers/ThemeManager/defaultThemes");
|
|
381
381
|
(0, import_utils.registerTldrawLibraryVersion)(
|
|
382
382
|
"@tldraw/editor",
|
|
383
|
-
"5.2.0-
|
|
383
|
+
"5.2.0-next.5d769d321393",
|
|
384
384
|
"cjs"
|
|
385
385
|
);
|
|
386
386
|
//# sourceMappingURL=index.js.map
|
|
@@ -2340,6 +2340,11 @@ class Editor extends import_eventemitter3.default {
|
|
|
2340
2340
|
getConstrainedCamera(point, opts) {
|
|
2341
2341
|
const currentCamera = this.getCamera();
|
|
2342
2342
|
let { x, y, z = currentCamera.z } = point;
|
|
2343
|
+
const preserveFocalPoint = (current, requested, rz, z2) => {
|
|
2344
|
+
const cz = currentCamera.z;
|
|
2345
|
+
if (rz === cz) return current;
|
|
2346
|
+
return current + (requested - current) * (1 / z2 - 1 / cz) / (1 / rz - 1 / cz);
|
|
2347
|
+
};
|
|
2343
2348
|
if (!opts?.force) {
|
|
2344
2349
|
const cameraOptions = this.getCameraOptions();
|
|
2345
2350
|
const zoomMin = cameraOptions.zoomSteps[0];
|
|
@@ -2359,14 +2364,10 @@ class Editor extends import_eventemitter3.default {
|
|
|
2359
2364
|
z = this.getInitialZoom();
|
|
2360
2365
|
}
|
|
2361
2366
|
if (z < minZ || z > maxZ) {
|
|
2362
|
-
const
|
|
2363
|
-
const cxA = -cx + vsb.w / cz / 2;
|
|
2364
|
-
const cyA = -cy + vsb.h / cz / 2;
|
|
2367
|
+
const rz = z;
|
|
2365
2368
|
z = (0, import_utils2.clamp)(z, minZ, maxZ);
|
|
2366
|
-
|
|
2367
|
-
|
|
2368
|
-
x = cx + cxB - cxA;
|
|
2369
|
-
y = cy + cyB - cyA;
|
|
2369
|
+
x = preserveFocalPoint(currentCamera.x, x, rz, z);
|
|
2370
|
+
y = preserveFocalPoint(currentCamera.y, y, rz, z);
|
|
2370
2371
|
}
|
|
2371
2372
|
const minX = px / z - bounds.x;
|
|
2372
2373
|
const minY = py / z - bounds.y;
|
|
@@ -2435,10 +2436,10 @@ class Editor extends import_eventemitter3.default {
|
|
|
2435
2436
|
}
|
|
2436
2437
|
} else {
|
|
2437
2438
|
if (z > zoomMax || z < zoomMin) {
|
|
2438
|
-
const
|
|
2439
|
+
const rz = z;
|
|
2439
2440
|
z = (0, import_utils2.clamp)(z, zoomMin, zoomMax);
|
|
2440
|
-
x =
|
|
2441
|
-
y =
|
|
2441
|
+
x = preserveFocalPoint(currentCamera.x, x, rz, z);
|
|
2442
|
+
y = preserveFocalPoint(currentCamera.y, y, rz, z);
|
|
2442
2443
|
}
|
|
2443
2444
|
}
|
|
2444
2445
|
}
|