Browse Source

Introduce CSS transformation functions scaleX, scaleY, scaleZ

CSS_TRANSFORMATION
Shagen Ogandzhanian 3 years ago
parent
commit
8f4a853db6
  1. 4
      web/core/src/jsMain/kotlin/org/jetbrains/compose/web/css/properties/transform.kt
  2. 25
      web/core/src/jsTest/kotlin/css/TransformTests.kt

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

@ -31,6 +31,10 @@ fun rotateZTransform(a: CSSAngleValue) = TransformFunction { "rotateZ($a)" }
fun scaleTransform(sx: Number) = TransformFunction { "scale($sx)" } fun scaleTransform(sx: Number) = TransformFunction { "scale($sx)" }
fun scaleTransform(sx: Number, sy: Number) = TransformFunction { "scale($sx, $sy)" } fun scaleTransform(sx: Number, sy: Number) = TransformFunction { "scale($sx, $sy)" }
fun scale3dTransform(sx: Number, sy: Number, sz: Number) = TransformFunction { "scale3d($sx, $sy, $sz)" } fun scale3dTransform(sx: Number, sy: Number, sz: Number) = TransformFunction { "scale3d($sx, $sy, $sz)" }
fun scaleXTransform(s: Number) = TransformFunction { "scaleX($s)" }
fun scaleYTransform(s: Number) = TransformFunction { "scaleY($s)" }
fun scaleZTransform(s: Number) = TransformFunction { "scaleZ($s)" }
fun StyleBuilder.transform(transformFunction: TransformFunction) { fun StyleBuilder.transform(transformFunction: TransformFunction) {
property("transform", transformFunction.apply()) property("transform", transformFunction.apply())

25
web/core/src/jsTest/kotlin/css/TransformTests.kt

@ -116,5 +116,30 @@ class TransformTests {
assertEquals("scale3d(0.2, 0.3, 0.1)", nextChild().style.transform) assertEquals("scale3d(0.2, 0.3, 0.1)", nextChild().style.transform)
} }
@Test
fun scaleX() = runTest {
composition {
Div({ style { transform(scaleXTransform(0.5)) } })
}
assertEquals("scaleX(0.5)", nextChild().style.transform)
}
@Test
fun scaleY() = runTest {
composition {
Div({ style { transform(scaleYTransform(0.7)) } })
}
assertEquals("scaleY(0.7)", nextChild().style.transform)
}
@Test
fun scaleZ() = runTest {
composition {
Div({ style { transform(scaleZTransform(0.12)) } })
}
assertEquals("scaleZ(0.12)", nextChild().style.transform)
}
} }
Loading…
Cancel
Save