selector initial implementation

This commit is contained in:
barsdeveloper
2021-09-08 23:02:34 +02:00
parent b434868fa8
commit 6b8b52ff37
6 changed files with 211 additions and 48 deletions

View File

@@ -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() {