Browse Source

tranformation fun matrix

CSS_TRANSFORMATION
Shagen Ogandzhanian 3 years ago
parent
commit
0eded0209a
  1. 19
      web/core/src/jsMain/kotlin/org/jetbrains/compose/web/css/properties/transform.kt
  2. 24
      web/core/src/jsTest/kotlin/css/TransitionTests.kt

19
web/core/src/jsMain/kotlin/org/jetbrains/compose/web/css/properties/transform.kt

@ -0,0 +1,19 @@
/*
* Copyright 2020-2021 JetBrains s.r.o. and respective authors and developers.
* Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE.txt file.
*/
package org.jetbrains.compose.web.css
fun interface TransformFunction {
fun apply(): String
}
fun matrixTransform(a: Number, b: Number, c: Number, d: Number, tx: Number, ty: Number)
= TransformFunction { "matrix($a, $b, $c, $d, $tx, $ty)" }
fun StyleBuilder.transform(transformFunction: TransformFunction) {
property("transform", transformFunction.apply())
}

24
web/core/src/jsTest/kotlin/css/TransitionTests.kt

@ -0,0 +1,24 @@
/*
* Copyright 2020-2021 JetBrains s.r.o. and respective authors and developers.
* Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE.txt file.
*/
package org.jetbrains.compose.web.core.tests.css
import org.jetbrains.compose.web.core.tests.runTest
import org.jetbrains.compose.web.css.matrixTransform
import org.jetbrains.compose.web.css.transform
import org.jetbrains.compose.web.dom.Div
import kotlin.test.Test
import kotlin.test.assertEquals
class TransitionTests {
@Test
fun matrix() = runTest {
composition {
Div({style { transform(matrixTransform(1, 2, -1, 1, 80, 80)) }})
}
assertEquals("matrix(1, 2, -1, 1, 80, 80)", nextChild().style.transform)
}
}
Loading…
Cancel
Save