mirror of
https://github.com/barsdeveloper/ueblueprint.git
synced 2026-03-02 05:04:43 +08:00
Resizeable comments
This commit is contained in:
@@ -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],
|
||||
])
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user