layerchart 0.98.0 → 0.98.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.
|
@@ -58,7 +58,7 @@
|
|
|
58
58
|
import { motionStore, type MotionOptions, motionFinishHandler } from '../stores/motionStore.js';
|
|
59
59
|
import { localPoint } from '@layerstack/utils';
|
|
60
60
|
|
|
61
|
-
const { width, height } = chartContext();
|
|
61
|
+
const { width, height, padding } = chartContext();
|
|
62
62
|
|
|
63
63
|
export let mode: TransformMode = 'none';
|
|
64
64
|
|
|
@@ -112,11 +112,11 @@
|
|
|
112
112
|
}
|
|
113
113
|
|
|
114
114
|
export function zoomIn() {
|
|
115
|
-
scaleTo(1.25, { x: $width / 2, y: $height / 2 });
|
|
115
|
+
scaleTo(1.25, { x: ($width + $padding.left) / 2, y: ($height + $padding.top) / 2 });
|
|
116
116
|
}
|
|
117
117
|
|
|
118
118
|
export function zoomOut() {
|
|
119
|
-
scaleTo(0.8, { x: $width / 2, y: $height / 2 });
|
|
119
|
+
scaleTo(0.8, { x: ($width + $padding.left) / 2, y: ($height + $padding.top) / 2 });
|
|
120
120
|
}
|
|
121
121
|
|
|
122
122
|
export function translateCenter() {
|
|
@@ -245,12 +245,12 @@
|
|
|
245
245
|
|
|
246
246
|
// Translate towards point (ex. mouse cursor/center) while zooming in/out
|
|
247
247
|
const invertTransformPoint = {
|
|
248
|
-
x: (point.x - $translate.x) / currentScale,
|
|
249
|
-
y: (point.y - $translate.y) / currentScale,
|
|
248
|
+
x: (point.x - $padding.left - $translate.x) / currentScale,
|
|
249
|
+
y: (point.y - $padding.top - $translate.y) / currentScale,
|
|
250
250
|
};
|
|
251
251
|
const newTranslate = {
|
|
252
|
-
x: point.x - invertTransformPoint.x * newScale,
|
|
253
|
-
y: point.y - invertTransformPoint.y * newScale,
|
|
252
|
+
x: point.x - $padding.left - invertTransformPoint.x * newScale,
|
|
253
|
+
y: point.y - $padding.top - invertTransformPoint.y * newScale,
|
|
254
254
|
};
|
|
255
255
|
setTranslate(newTranslate, options);
|
|
256
256
|
}
|