Browse Source

Update onMouseUp to prevent minus height and width

pull/1899/head
Hironsan 2 years ago
parent
commit
fe16429d1f
1 changed files with 13 additions and 3 deletions
  1. 16
      frontend/components/tasks/boundingBox/VBoundingBox.vue

16
frontend/components/tasks/boundingBox/VBoundingBox.vue

@ -220,13 +220,23 @@ export default Vue.extend({
onMouseUp() {
if (this.newRectangle && this.newRectangle.exists()) {
const sx = this.newRectangle.x
const sy = this.newRectangle.y
const pos = this.stage.getPointerPosition()!
const { x: stageX = 0, y: stageY = 0 } = this.stage.attrs
pos.x = transform(pos.x, stageX, this.scale)
pos.y = transform(pos.y, stageY, this.scale)
const annotationToAdd = this.newRectangle.transform(sx, sy, pos.x - sx, pos.y - sy)
let x = this.newRectangle.x
let y = this.newRectangle.y
let width = pos.x - x
let height = pos.y - y
if (width < 0) {
x += width
width = -width
}
if (height < 0) {
y += height
height = -height
}
const annotationToAdd = this.newRectangle.transform(x, y, width, height)
this.newRectangle = null
this.configStage.draggable = true
this.$emit('add-rectangle', annotationToAdd.toProps())

Loading…
Cancel
Save