| if (this.cursorAttachedNode != null) { | if (this.cursorAttachedNode != null) { | ||||
| let node = this.cursorAttachedNode; | let node = this.cursorAttachedNode; | ||||
| let newX = Math.round(x - node.width / 2); | let newX = Math.round(x - node.width / 2); | ||||
| let newY = Math.round(y - node.height / 2); | |||||
| let newY = Math.round(y - node.height / 2 + 0.5); | |||||
| if (newX != node.x || newY != node.y) { | if (newX != node.x || newY != node.y) { | ||||
| node.x = newX; | node.x = newX; | ||||
| node.y = newY; | node.y = newY; | ||||
| if (this.cursorAttachedNode != null) { | if (this.cursorAttachedNode != null) { | ||||
| let node = this.cursorAttachedNode; | let node = this.cursorAttachedNode; | ||||
| node.x = Math.round(x - node.width / 2); | node.x = Math.round(x - node.width / 2); | ||||
| node.y = Math.round(y - node.height / 2); | |||||
| node.y = Math.round(y - node.height / 2 + 0.5); | |||||
| this.cursorAttachedNode = null; | this.cursorAttachedNode = null; | ||||
| return; | return; | ||||
| } | } | ||||
| addNodeAtCursor(node) { | addNodeAtCursor(node) { | ||||
| node.x = Math.round(this.cursorX - node.width / 2); | node.x = Math.round(this.cursorX - node.width / 2); | ||||
| node.y = Math.round(this.cursorY - node.height / 2); | |||||
| node.y = Math.round(this.cursorY - node.height / 2 + 0.5); | |||||
| this.nodes.push(node); | this.nodes.push(node); | ||||
| this.cursorAttachedNode = node; | this.cursorAttachedNode = node; | ||||
| this.requestFrame(); | this.requestFrame(); |