Commit 8320c52
committed
fix: normalize canvas dimensions in ItemEventsMixin to support zoom
The mixin was returning canvas.width/height which changes when the
VuePdfEditor scale property changes (zoom). This caused element
positioning issues:
- Elements would move to (0,0) on initial render
- Drag boundaries would be incorrect after zoom
- Saved coordinates would be inconsistent
This fix caches the normalized canvas dimensions (at scale 1.0) and
returns them consistently, ensuring elements maintain correct
positioning regardless of zoom level.
The implementation:
- Lazy initializes normalized dimensions on first call
- Traverses parent tree to find VuePdfEditor and get current scale
- Divides canvas dimensions by scale to normalize to 1.0
- Returns large values during initial render to avoid constraining
Benefits all components using the mixin:
- TextItem.vue
- Image.vue
- Drawing.vue
- DrawingCanvas.vue
- Custom components (e.g., Signature.vue)
Fixes element positioning with zoom operations.
Signed-off-by: Vitor Mattos <1079143+vitormattos@users.noreply.github.com>1 parent 01fdda9 commit 8320c52
1 file changed
+24
-8
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
5 | 5 | | |
6 | 6 | | |
7 | 7 | | |
| 8 | + | |
| 9 | + | |
8 | 10 | | |
9 | 11 | | |
10 | 12 | | |
11 | 13 | | |
12 | 14 | | |
13 | 15 | | |
14 | | - | |
15 | | - | |
16 | | - | |
17 | | - | |
18 | | - | |
19 | | - | |
20 | | - | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
21 | 29 | | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
22 | 39 | | |
23 | | - | |
24 | 40 | | |
25 | 41 | | |
26 | 42 | | |
| |||
0 commit comments