Skip to content

Commit 9ed184b

Browse files
author
陈璐
committed
bugfix: when lockAspectRatio, resize lm and rt inrorrect
1 parent 72cda08 commit 9ed184b

File tree

1 file changed

+22
-4
lines changed

1 file changed

+22
-4
lines changed

src/components/vue-draggable-resizable.vue

+22-4
Original file line numberDiff line numberDiff line change
@@ -251,6 +251,7 @@ export default {
251251
parentHeight: null,
252252
253253
handle: null,
254+
realHandle: null,
254255
enabled: this.active,
255256
resizing: false,
256257
dragging: false,
@@ -455,6 +456,7 @@ export default {
455456
} else {
456457
this.handle = handle
457458
}
459+
this.realHandle = handle;
458460
459461
this.resizeEnable = true
460462
@@ -656,7 +658,11 @@ export default {
656658
)
657659
658660
if (this.lockAspectRatio && this.resizingOnY) {
659-
right = this.right - (this.bottom - bottom) * aspectFactor
661+
if (this.realHandle.includes("r")) {
662+
right = this.right - (this.bottom - bottom) * aspectFactor;
663+
} else {
664+
left = this.left - (this.bottom - bottom) * aspectFactor;
665+
}
660666
}
661667
} else if (this.handle.includes('t')) {
662668
top = restrictToBounds(
@@ -666,7 +672,11 @@ export default {
666672
)
667673
668674
if (this.lockAspectRatio && this.resizingOnY) {
669-
left = this.left - (this.top - top) * aspectFactor
675+
if (this.realHandle.includes("r")) {
676+
right = this.right - (this.top - top) * aspectFactor;
677+
} else {
678+
left = this.left - (this.top - top) * aspectFactor;
679+
}
670680
}
671681
}
672682
@@ -678,7 +688,11 @@ export default {
678688
)
679689
680690
if (this.lockAspectRatio && this.resizingOnX) {
681-
bottom = this.bottom - (this.right - right) / aspectFactor
691+
if (this.realHandle.includes("b")) {
692+
bottom = this.bottom - (this.right - right) / aspectFactor;
693+
} else {
694+
top = this.top - (this.right - right) / aspectFactor;
695+
}
682696
}
683697
} else if (this.handle.includes('l')) {
684698
left = restrictToBounds(
@@ -688,7 +702,11 @@ export default {
688702
)
689703
690704
if (this.lockAspectRatio && this.resizingOnX) {
691-
top = this.top - (this.left - left) / aspectFactor
705+
if (this.realHandle.includes("b")) {
706+
bottom = this.bottom - (this.left - left) / aspectFactor;
707+
} else {
708+
top = this.top - (this.left - left) / aspectFactor;
709+
}
692710
}
693711
}
694712

0 commit comments

Comments
 (0)