aboutsummaryrefslogtreecommitdiff
path: root/src/main/kotlin/pl/treksoft/kvision/utils
diff options
context:
space:
mode:
authorRobert Jaros <rjaros@finn.pl>2020-05-20 15:13:08 +0200
committerRobert Jaros <rjaros@finn.pl>2020-05-20 15:15:16 +0200
commit5e25011690115a6787232c47c1d8558d1af82426 (patch)
tree1c2a244fcde7b604cde3f069ae7fa0afa31da70e /src/main/kotlin/pl/treksoft/kvision/utils
parent6c1c0e7bb02843a8088a011dbfb224605c201dd7 (diff)
downloadkvision-5e25011690115a6787232c47c1d8558d1af82426.tar.gz
kvision-5e25011690115a6787232c47c1d8558d1af82426.tar.bz2
kvision-5e25011690115a6787232c47c1d8558d1af82426.zip
Support for jQuery animations (#154)
Diffstat (limited to 'src/main/kotlin/pl/treksoft/kvision/utils')
-rw-r--r--src/main/kotlin/pl/treksoft/kvision/utils/Utils.kt23
1 files changed, 23 insertions, 0 deletions
diff --git a/src/main/kotlin/pl/treksoft/kvision/utils/Utils.kt b/src/main/kotlin/pl/treksoft/kvision/utils/Utils.kt
index e2833630..995b0466 100644
--- a/src/main/kotlin/pl/treksoft/kvision/utils/Utils.kt
+++ b/src/main/kotlin/pl/treksoft/kvision/utils/Utils.kt
@@ -161,6 +161,20 @@ fun CssSize.asString(): String {
}
}
+/**
+ * Extension operator to increase CssSize units.
+ */
+operator fun CssSize?.plus(i: Number): CssSize {
+ return this?.let { CssSize(it.first.toDouble() + i.toDouble(), it.second) } ?: CssSize(i, UNIT.px)
+}
+
+/**
+ * Extension operator to decrease CssSize units.
+ */
+operator fun CssSize?.minus(i: Number): CssSize {
+ return this?.let { CssSize(it.first.toDouble() - i.toDouble(), it.second) } ?: CssSize(i, UNIT.px)
+}
+
private val hex = arrayOf("0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "a", "b", "c", "d", "e", "f")
/**
@@ -208,3 +222,12 @@ val String?.set: Set<String>
get() {
return this?.split(Regex("\\s+"))?.toSet() ?: setOf()
}
+
+/**
+ * Utility extension function to convert string from kebab-case to camelCase.
+ */
+fun String.toCamelCase(): String {
+ return this.replace(Regex("(\\-\\w)")) {
+ it.value.drop(1).toUpperCase()
+ }
+}