Commit f433e108 authored by Anton Koch's avatar Anton Koch

Merge branch '322-move-cell-outside-grid-fix---mosys' into 'master'

prevent moving a cell outside the grid via panning (#322)

See merge request !27
parents 556385d7 5f979fa1
Pipeline #49839 passed with stage
in 5 minutes and 16 seconds
......@@ -255,7 +255,7 @@
resize: {left: undefined, intersectingMainHandler: false, side: undefined}
},
selectedCell: {type: undefined, annotation: undefined, x: undefined, y: undefined, w: undefined, h: undefined},
pannedCell: {annotation: undefined, panned: false, x: undefined, y: undefined, w: undefined, h: undefined, offset: {x: undefined, y: undefined}}
pannedCell: {annotation: undefined, panned: false, x: undefined, y: undefined, w: undefined, h: undefined, offset: {x: undefined, y: undefined}, offsetNew: undefined}
}
},
computed: {
......@@ -360,10 +360,26 @@
handler: function (cursor) {
let
pannedCell = this.pannedCell,
x = cursor.x - pannedCell.offset.x,
y = cursor.y - pannedCell.offset.y
if (pannedCell) this.setCellPosition(pannedCell.annotation, x, y)
gridRows = this.data.configuration.rows,
gridColumns = this.data.configuration.columns,
cellTop = pannedCell.y - pannedCell.offset.y - 1,
cellBottom = (pannedCell.y - pannedCell.offset.y) + pannedCell.h - 1,
cellLeft = pannedCell.x - pannedCell.offset.y - 1,
cellRight = (pannedCell.x - pannedCell.offset.x) + pannedCell.w - 1
let x
if (cellRight > gridColumns) x = gridColumns - pannedCell.w + 1
else if (cellLeft < 0) x = 0
else x = cursor.x - pannedCell.offset.x
let y
if (cellBottom > gridRows) y = gridRows - pannedCell.h + 1
else if (cellTop < 0) y = 0
else y = cursor.y - pannedCell.offset.y
if (pannedCell) {
this.setCellPosition(pannedCell.annotation, x, y)
}
},
deep: true
},
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment