What's the language equivalent of do nothing next? #477
-
I have my component: record Node.Rec {
id : String,
x : Number,
y : Number
}
enum Node.Action {
None
Clicked
}
component Node {
property node : Node.Rec
property radius : Number
state action = Node.Action::None
fun moveNode(element : Dom.Element, x : Number, y : Number) {
element
|> Dom.setAttribute("x", Number.toString(x))
|> Dom.setAttribute("y", Number.toString(y))
}
fun onDrag(event : Html.Event) {
if (action == Node.Action::Clicked) {
case (circle) {
Maybe::Just(el) => moveNode(el, event.clientX, event.clientY)
=> next {}
}
} else {
next {}
}
}
/*
fun onDragEnd(event) {
}
*/
fun render : Html {
<circle as circle
onMouseDown={() {
next { action = Node.Action::Clicked }
}}
onMouseMove={onDrag}
cx={Number.toString(node.x)}
cy={Number.toString(node.y)}
fill="red"
r={Number.toString(radius)}
/>
}
}
|
Beta Was this translation helpful? Give feedback.
Answered by
WhoAteDaCake
Jul 21, 2021
Replies: 1 comment
-
Actually related discussion is just bellow #455 |
Beta Was this translation helpful? Give feedback.
0 replies
Answer selected by
WhoAteDaCake
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Actually related discussion is just bellow #455