mirror of
https://github.com/barsdeveloper/ueblueprint.git
synced 2026-03-12 11:07:40 +08:00
Window introduced
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
import Configuration from "../../Configuration"
|
||||
import IMouseClickDrag from "./IMouseClickDrag"
|
||||
import MouseMoveDraggable from "./MouseMoveDraggable"
|
||||
import Utility from "../../Utility"
|
||||
|
||||
/**
|
||||
@@ -7,21 +7,10 @@ import Utility from "../../Utility"
|
||||
* @typedef {import("../../element/ISelectableDraggableElement").default} ISelectableDraggableElement
|
||||
*/
|
||||
|
||||
/**
|
||||
* @extends {IMouseClickDrag<ISelectableDraggableElement>}
|
||||
*/
|
||||
export default class MouseMoveNodes extends IMouseClickDrag {
|
||||
|
||||
constructor(target, blueprint, options) {
|
||||
super(target, blueprint, options)
|
||||
this.stepSize = parseInt(options?.stepSize ?? Configuration.gridSize)
|
||||
this.mouseLocation = [0, 0]
|
||||
}
|
||||
/** @extends {IMouseClickDrag<ISelectableDraggableElement>} */
|
||||
export default class MouseMoveNodes extends MouseMoveDraggable {
|
||||
|
||||
startDrag() {
|
||||
// Get the current mouse position
|
||||
this.mouseLocation = Utility.snapToGrid(this.clickedPosition, this.stepSize)
|
||||
|
||||
if (!this.target.selected) {
|
||||
this.blueprint.unselectAll()
|
||||
this.target.setSelected(true)
|
||||
@@ -37,17 +26,13 @@ export default class MouseMoveNodes extends IMouseClickDrag {
|
||||
mouseLocation[0] - this.mouseLocation[0],
|
||||
mouseLocation[1] - this.mouseLocation[1]
|
||||
]
|
||||
|
||||
if (d[0] == 0 && d[1] == 0) {
|
||||
return
|
||||
}
|
||||
|
||||
// Make sure it snaps on the grid
|
||||
d[0] += targetLocation[0] - this.target.locationX
|
||||
d[1] += targetLocation[1] - this.target.locationY
|
||||
|
||||
this.target.dispatchDragEvent(d)
|
||||
|
||||
// Reassign the position of mouse
|
||||
this.mouseLocation = mouseLocation
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user