From 0eded0209a65df9e44ac94d5d138a0c0a92e3eae Mon Sep 17 00:00:00 2001 From: Shagen Ogandzhanian Date: Wed, 18 Aug 2021 19:13:23 +0200 Subject: [PATCH] tranformation fun matrix --- .../compose/web/css/properties/transform.kt | 19 +++++++++++++++ .../src/jsTest/kotlin/css/TransitionTests.kt | 24 +++++++++++++++++++ 2 files changed, 43 insertions(+) create mode 100644 web/core/src/jsMain/kotlin/org/jetbrains/compose/web/css/properties/transform.kt create mode 100644 web/core/src/jsTest/kotlin/css/TransitionTests.kt diff --git a/web/core/src/jsMain/kotlin/org/jetbrains/compose/web/css/properties/transform.kt b/web/core/src/jsMain/kotlin/org/jetbrains/compose/web/css/properties/transform.kt new file mode 100644 index 0000000000..1572985c74 --- /dev/null +++ b/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()) +} \ No newline at end of file diff --git a/web/core/src/jsTest/kotlin/css/TransitionTests.kt b/web/core/src/jsTest/kotlin/css/TransitionTests.kt new file mode 100644 index 0000000000..2b90d3e62b --- /dev/null +++ b/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) + } +} \ No newline at end of file