Skip to content

Commit 0c4cb08

Browse files
authored
Merge pull request #112 from LibreSign/fix/prevent-move-drawing-element-to-outside-of-page
fix: prevent move drawing element to outside of page
2 parents 0b78b1b + 9e89a11 commit 0c4cb08

File tree

2 files changed

+11
-5
lines changed

2 files changed

+11
-5
lines changed

src/Components/Drawing.vue

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
:style="{
44
width: `${width + dw}px`,
55
height: `${(width + dw) / ratio}px`,
6-
transform: `translate(${x + dx}px, ${y + dy}px)`,
6+
transform: translateCoordinates(),
77
}">
88
<div class="
99
absolute
@@ -58,6 +58,8 @@ export default {
5858
'x',
5959
'y',
6060
'pageScale',
61+
'pageWidth',
62+
'pageHeight',
6163
'path',
6264
],
6365
data() {
@@ -133,15 +135,15 @@ export default {
133135
134136
if (this.operation === 'move') {
135137
this.$emit('onUpdate', {
136-
x: this.x + this.dx,
137-
y: this.y + this.dy,
138+
x: coordinate.detail.x,
139+
y: coordinate.detail.y,
138140
})
139141
this.dx = 0
140142
this.dy = 0
141143
} else if (this.operation === 'scale') {
142144
this.$emit('onUpdate', {
143-
x: this.x + this.dx,
144-
y: this.y + this.dy,
145+
x: coordinate.detail.x,
146+
y: coordinate.detail.y,
145147
width: this.width + this.dw,
146148
scale: (this.width + this.dw) / this.originWidth,
147149
})

src/VuePdfEditor.vue

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -170,9 +170,12 @@
170170
:x="object.x"
171171
:y="object.y"
172172
:width="object.width"
173+
:height="object.height"
173174
:origin-width="object.originWidth"
174175
:origin-height="object.originHeight"
175176
:page-scale="pagesScale[pIndex]"
177+
:page-width="pageSizes[pIndex + 1].width"
178+
:page-height="pageSizes[pIndex + 1].height"
176179
@onUpdate="updateObject(object.id, $event)"
177180
@onDelete="deleteObject(object.id)" />
178181
</div>
@@ -620,6 +623,7 @@ export default {
620623
originWidth,
621624
originHeight,
622625
width: originWidth * scale,
626+
height: originHeight * scale,
623627
scale,
624628
}
625629
this.addObject(object)

0 commit comments

Comments
 (0)