Nikola Milovic
01/04/2022, 11:27 AM<motion.div
animate= {{x: [50, 0], opacity: [0,1]}} // X will go from 50% to 0% and opacity from 0% to 100%
I tried to translate the animate property with dynamics
val animate = js("{}")
animate.x = listOf(50, 0)
animate.opacity = listOf(0, 1)
When it gets converted to JS, the lists are ArrayLists instead of what I'd expect to be a List and even adding .toList
results in the same transformation.
For some reason this doesn't work, and I have to use
animate.x = js("[50,0]")
animate.opacity = js("[0,1]")
For it to work as expected , which doesn't allow me to pass parameters as js()
only accepts string literals
1.5.31
KotlinBig Chungus
01/04/2022, 11:28 AMBig Chungus
01/04/2022, 11:31 AMNikola Milovic
01/04/2022, 11:36 AMList
for the js("[50,0]")
hfhbd
01/04/2022, 12:04 PMkotlin.List
converts to the useful and common Swift.Array
in Objective-C, but on JS to a custom Kotlin class. Only on JS you have to use kotlin.Array
...Big Chungus
01/04/2022, 12:07 PMkotlin.Array
maps to primitive arrays on JVM as well. I've always did my best to stay away from apple stuff so can't comment on why swift interop deviates from this convention for kotlin.List
. What does kotlin.Array
translates to when compiled to obj-c? Does obj-c have a distinction between arrays and lists?hfhbd
01/04/2022, 12:08 PMhfhbd
01/04/2022, 12:22 PMKotlinIntArray
😄
Not really, objective-c has NSArray and NSMutableArray.Big Chungus
01/04/2022, 12:28 PMBig Chungus
01/04/2022, 12:41 PMFor it to work as expected , which doesn't allow me to pass parameters asFor completeness, this can be hacked as wellonly accepts string literalsjs()
fun main() {
var myVar = "Hello there!"
js("console.log(myVar)")
tmp = "General Kenobi"
js("console.log(myVar)")
}