From f63340e6324b557abb96cacc6df3d94f5b1fa71d Mon Sep 17 00:00:00 2001 From: Robert Jaros Date: Tue, 22 May 2018 14:35:45 +0200 Subject: Add resizeWindow event to Window component. --- src/main/kotlin/pl/treksoft/kvision/utils/Snabbdom.kt | 3 +++ src/main/kotlin/pl/treksoft/kvision/window/Window.kt | 8 ++++++++ 2 files changed, 11 insertions(+) diff --git a/src/main/kotlin/pl/treksoft/kvision/utils/Snabbdom.kt b/src/main/kotlin/pl/treksoft/kvision/utils/Snabbdom.kt index ccb11ff9..7bb18a58 100644 --- a/src/main/kotlin/pl/treksoft/kvision/utils/Snabbdom.kt +++ b/src/main/kotlin/pl/treksoft/kvision/utils/Snabbdom.kt @@ -56,6 +56,8 @@ private fun vNodeData(): VNodeData = js("({})") */ interface KvJQueryEventObject : JQueryEventObject { val clickedIndex: Int + val width: Int + val height: Int } /** @@ -100,6 +102,7 @@ interface BtOn : On { var fileResetUpload: ((KvEvent) -> kotlin.Unit)? var fileBrowseUpload: ((KvEvent) -> kotlin.Unit)? var filePreUpload: ((KvEvent) -> kotlin.Unit)? + var resizeWindow: ((KvEvent) -> kotlin.Unit)? } /** diff --git a/src/main/kotlin/pl/treksoft/kvision/window/Window.kt b/src/main/kotlin/pl/treksoft/kvision/window/Window.kt index 2b1aabb7..bdfb2c0f 100644 --- a/src/main/kotlin/pl/treksoft/kvision/window/Window.kt +++ b/src/main/kotlin/pl/treksoft/kvision/window/Window.kt @@ -36,6 +36,7 @@ import pl.treksoft.kvision.html.TAG import pl.treksoft.kvision.html.Tag import pl.treksoft.kvision.modal.CloseIcon import pl.treksoft.kvision.panel.SimplePanel +import pl.treksoft.kvision.utils.obj import pl.treksoft.kvision.utils.px internal const val DEFAULT_Z_INDEX = 900 @@ -230,6 +231,7 @@ open class Window( } } + @Suppress("UnsafeCastFromDynamic") private fun checkResizablEventHandler() { if (isResizable) { isResizeEvent = true @@ -244,6 +246,12 @@ open class Window( isResizable = true content.width = (intWidth - 2).px content.height = (intHeight - WINDOW_HEADER_HEIGHT - WINDOW_CONTENT_MARGIN_BOTTOM - 1 - 2).px + this.dispatchEvent("resizeWindow", obj { + detail = obj { + this.width = intWidth + this.height = intHeight + } + }) } } } else if (isResizeEvent) { -- cgit