mirror of
https://github.com/barsdeveloper/ueblueprint.git
synced 2026-05-17 10:17:29 +08:00
selector initial implementation
This commit is contained in:
@@ -4,7 +4,7 @@ export default class UEBlueprintDrag {
|
||||
this.mousePosition = [0, 0];
|
||||
this.stepSize = options?.stepSize
|
||||
this.clickButton = options?.clickButton ?? 0
|
||||
this.exitGrabSameButtonOnly = options?.exitGrabSameButtonOnly ?? false
|
||||
this.exitDragAnyButton = options?.exitDragAnyButton ?? true
|
||||
let self = this;
|
||||
this.mouseDownHandler = function (e) {
|
||||
switch (e.button) {
|
||||
@@ -12,7 +12,7 @@ export default class UEBlueprintDrag {
|
||||
self.clicked(e.clientX, e.clientY)
|
||||
break;
|
||||
default:
|
||||
if (!self.exitGrabSameButtonOnly) {
|
||||
if (!self.exitDragAnyButton) {
|
||||
self.mouseUpHandler(e)
|
||||
}
|
||||
break;
|
||||
@@ -32,15 +32,14 @@ export default class UEBlueprintDrag {
|
||||
self.mousePosition = mousePosition
|
||||
};
|
||||
this.mouseUpHandler = function (e) {
|
||||
if (!self.exitGrabSameButtonOnly || e.button == self.clickButton) {
|
||||
if (!self.exitDragAnyButton || e.button == self.clickButton) {
|
||||
// Remove the handlers of `mousemove` and `mouseup`
|
||||
document.removeEventListener('mousemove', self.mouseMoveHandler)
|
||||
document.removeEventListener('mouseup', self.mouseUpHandler)
|
||||
}
|
||||
};
|
||||
let element = this.blueprintNode
|
||||
element.addEventListener('mousedown', this.mouseDownHandler)
|
||||
element.addEventListener('contextmenu', e => e.preventDefault())
|
||||
this.blueprintNode.addEventListener('mousedown', this.mouseDownHandler)
|
||||
this.blueprintNode.addEventListener('contextmenu', e => e.preventDefault())
|
||||
}
|
||||
|
||||
unlistenDOMElement() {
|
||||
|
||||
Reference in New Issue
Block a user