Shubham Singh
11/27/2024, 2:07 AMRobert Jaros
11/27/2024, 8:46 AMRobert Jaros
11/27/2024, 8:46 AMRobert Jaros
11/27/2024, 8:47 AMimplementation(npm("motion", "*"))
in build.gradle.kts
Robert Jaros
11/27/2024, 8:47 AM@JsModule("motion")
external object Motion : JsAny {
fun animate(element: Element, keyframes: JsAny)
fun animate(selector: String, keyframes: JsAny)
fun animate(element: Element, keyframes: JsAny, options: JsAny)
fun animate(selector: String, keyframes: JsAny, options: JsAny)
}
Robert Jaros
11/27/2024, 8:48 AMdiv("box") {
width(100.px)
height(100.px)
background(Background(color = Color.rgb(255, 0, 0)))
}
button("Animate background") {
onClick {
Motion.animate(".box", jsObjectOf("background" to "rgb(0, 255, 0)"))
}
}
button("Start rotating") {
onClick {
Motion.animate(
".box",
jsObjectOf("rotate" to 90),
jsObjectOf(
"type" to "spring",
"stiffness" to 300,
"repeat" to Int.MAX_VALUE,
"repeatDelay" to 0.2
)
)
}
}
Shubham Singh
11/27/2024, 8:51 AMRobert Jaros
11/27/2024, 9:03 AMShubham Singh
11/27/2024, 9:08 AMShubham Singh
11/27/2024, 9:09 AMderivedStateOf
and movableContentOf
that don't make a lot of sense unless we're actually animating and/or changing states very frequently.Maanrifa Bacar Ali
11/28/2024, 7:46 AMRobert Jaros
11/28/2024, 9:27 AManimate*AsState
calls with simple specs (at least tween and spring were working).