@@ -5,22 +5,38 @@ export default {
55 return {
66 x_mixin: null ,
77 y_mixin: null ,
8+ initialCanvasWidth: null ,
9+ initialCanvasHeight: null ,
810 }
911 },
1012 created () {},
1113 methods: {
1214 getCurrentPageDimensions () {
1315 const page = this .$el ? .closest (' .page' )
14- if (page) {
15- const canvas = page .querySelector (' canvas' )
16- if (canvas) {
17- return {
18- pageWidth: canvas .width ,
19- pageHeight: canvas .height ,
20- }
16+ if (! page) {
17+ return { pageWidth: 999999 , pageHeight: 999999 }
18+ }
19+
20+ const canvas = page .querySelector (' canvas' )
21+ if (! canvas) {
22+ return { pageWidth: 999999 , pageHeight: 999999 }
23+ }
24+
25+ if (! this .initialCanvasWidth ) {
26+ let component = this .$parent
27+ while (component && component .$options .name !== ' VuePdfEditor' ) {
28+ component = component .$parent
2129 }
30+ const currentScale = component? .scale || 1
31+
32+ this .initialCanvasWidth = canvas .width / currentScale
33+ this .initialCanvasHeight = canvas .height / currentScale
34+ }
35+
36+ return {
37+ pageWidth: this .initialCanvasWidth ,
38+ pageHeight: this .initialCanvasHeight ,
2239 }
23- return { pageWidth: 0 , pageHeight: 0 }
2440 },
2541 handleMousedown (event ) {
2642 this .x_mixin = event .clientX
0 commit comments