Resizeable comments

This commit is contained in:
barsdeveloper
2022-12-04 22:12:53 +01:00
parent 41e1ffd59b
commit 9e8e25d832
19 changed files with 1103 additions and 443 deletions

View File

@@ -23,29 +23,32 @@ export default class MouseMoveDraggable extends IMouseClickDrag {
}
dragTo(location, offset) {
const targetLocation = [this.target.locationX, this.target.locationY]
const targetLocation = [
this.target.locationX ?? this.lastLocation[0],
this.target.locationY ?? this.lastLocation[1],
]
const [adjustedLocation, adjustedTargetLocation] = this.stepSize > 1
? [Utility.snapToGrid(location, this.stepSize), Utility.snapToGrid(targetLocation, this.stepSize)]
: [location, targetLocation]
offset = [
adjustedLocation[0] - this.mouseLocation[0],
adjustedLocation[1] - this.mouseLocation[1]
adjustedLocation[0] - this.lastLocation[0],
adjustedLocation[1] - this.lastLocation[1],
]
if (offset[0] == 0 && offset[1] == 0) {
return
}
// Make sure it snaps on the grid
offset[0] += adjustedTargetLocation[0] - this.target.locationX
offset[1] += adjustedTargetLocation[1] - this.target.locationY
offset[0] += adjustedTargetLocation[0] - targetLocation[0]
offset[1] += adjustedTargetLocation[1] - targetLocation[1]
this.dragAction(adjustedLocation, offset)
// Reassign the position of mouse
this.mouseLocation = adjustedLocation
this.lastLocation = adjustedLocation
}
dragAction(location, offset) {
this.target.setLocation([
location[0] - this.clickedOffset[0],
location[1] - this.clickedOffset[1]
location[1] - this.clickedOffset[1],
])
}
}