Browse Source

Introduce CSS transformation function scale

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

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

@ -28,6 +28,9 @@ fun rotateX(a: CSSAngleValue) = TransformFunction { "rotateX($a)" }
fun rotateY(a: CSSAngleValue) = TransformFunction { "rotateY($a)" }
fun rotateZ(a: CSSAngleValue) = TransformFunction { "rotateZ($a)" }
fun scaleTransform(sx: Number) = TransformFunction { "scale($sx)" }
fun scaleTransform(sx: Number, sy: Number) = TransformFunction { "scale($sx, $sy)" }
fun StyleBuilder.transform(transformFunction: TransformFunction) {
property("transform", transformFunction.apply())
}

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

@ -96,4 +96,15 @@ class TransformTests {
assertEquals("rotateZ(3.14rad)", nextChild().style.transform)
}
@Test
fun scale() = runTest {
composition {
Div({ style { transform(scaleTransform(0.6)) } })
Div({ style { transform(scaleTransform(0.2, 0.3)) } })
}
assertEquals("scale(0.6)", nextChild().style.transform)
assertEquals("scale(0.2, 0.3)", nextChild().style.transform)
}
}
Loading…
Cancel
Save