Skip to content

Conversation

@vitormattos
Copy link
Member

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.

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>
@vitormattos vitormattos self-assigned this Dec 2, 2025
@vitormattos vitormattos merged commit 25db926 into main Dec 2, 2025
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants