Commit cb35515b authored by Tobias Liese's avatar Tobias Liese

begin transition logic

parent 8439cc2d
Pipeline #93859 failed with stages
in 33 seconds
......@@ -20,7 +20,7 @@ class Field {
});
document.getElementById("addTransition").addEventListener("mousedown", () => {
transitionMode = true
document.body.style.cursor = "crosshair"
// document.body.style.cursor = "crosshair"
});
}
......@@ -54,7 +54,11 @@ class Field {
}
drawLineTo(x: number, y: number) {
// this.context.arcTo(this.getStateByIndex(selected).x)
this.context.strokeStyle = "white"
this.context.beginPath()
this.context.moveTo(this.getStateByIndex(lastSelected).x, this.getStateByIndex(lastSelected).y)
this.context.lineTo(x, y)
this.context.stroke()
}
rePaint() {
......@@ -117,12 +121,19 @@ class State {
// listener:
onmousemove = (event: MouseEvent) => {
let x = event.clientX - field.xOrigin
let y = event.clientY - field.yOrigin
if (dragMode) {
field.updateState(selected, event.x - field.xOrigin, event.y - field.yOrigin, null)
field.updateState(selected, x, y, null)
} else if (menuVisible) {
selected = field.getStateIndex(event.clientX - field.xOrigin, event.clientY - field.yOrigin)
selected = field.getStateIndex(x, y)
if (selected != null) {
lastSelected = selected
}
if (transitionMode) {
document.body.style.cursor = "crosshair"
document.body.style.cursor = "default"
field.rePaint()
field.drawLineTo(x, y)
} else if (selected != null) {
document.body.style.cursor = "grab"
} else {
......@@ -188,6 +199,7 @@ const field: Field = new Field();
let states = document.getElementById("states");
let contextMenu
let selected: number
let lastSelected: number
// let webSocket = new WebSocket(
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment