diff options
author | Robert Jaros <rjaros@finn.pl> | 2019-01-29 20:30:34 +0100 |
---|---|---|
committer | Robert Jaros <rjaros@finn.pl> | 2019-01-29 20:30:34 +0100 |
commit | 6a527a913d73236694e2d509ee9a5583eb87491a (patch) | |
tree | 5613c2e7327d1aca307c15841bb5905eb982bc54 /src/main/kotlin/pl/treksoft/kvision/window/Window.kt | |
parent | e1bda40dc941517657df5940cf535363201fa884 (diff) | |
download | kvision-6a527a913d73236694e2d509ee9a5583eb87491a.tar.gz kvision-6a527a913d73236694e2d509ee9a5583eb87491a.tar.bz2 kvision-6a527a913d73236694e2d509ee9a5583eb87491a.zip |
More fixes for resizable windows.
Diffstat (limited to 'src/main/kotlin/pl/treksoft/kvision/window/Window.kt')
-rw-r--r-- | src/main/kotlin/pl/treksoft/kvision/window/Window.kt | 35 |
1 files changed, 17 insertions, 18 deletions
diff --git a/src/main/kotlin/pl/treksoft/kvision/window/Window.kt b/src/main/kotlin/pl/treksoft/kvision/window/Window.kt index 16e23e45..54b87e9d 100644 --- a/src/main/kotlin/pl/treksoft/kvision/window/Window.kt +++ b/src/main/kotlin/pl/treksoft/kvision/window/Window.kt @@ -134,7 +134,6 @@ open class Window( private val captionTag = Tag(TAG.H4, caption, classes = setOf("modal-title")) private var isResizeEvent = false - private var isResizing = false init { id = "kv_window_$counter" @@ -221,13 +220,13 @@ open class Window( checkResizablEventHandler() if (isResizable) { resize = Resize.BOTH - val intHeight = (getElementJQuery()?.height()?.toInt() ?: 0) + 2 - content.height = (intHeight - WINDOW_HEADER_HEIGHT - WINDOW_CONTENT_MARGIN_BOTTOM - 2).px + val intHeight = (getElementJQuery()?.height()?.toInt() ?: 0) + content.height = (intHeight - WINDOW_HEADER_HEIGHT - WINDOW_CONTENT_MARGIN_BOTTOM).px content.marginBottom = WINDOW_CONTENT_MARGIN_BOTTOM.px } else { resize = Resize.NONE - val intHeight = (getElementJQuery()?.height()?.toInt() ?: 0) + 2 - content.height = (intHeight - WINDOW_HEADER_HEIGHT - 2).px + val intHeight = (getElementJQuery()?.height()?.toInt() ?: 0) + content.height = (intHeight - WINDOW_HEADER_HEIGHT).px content.marginBottom = 0.px } } @@ -235,23 +234,23 @@ open class Window( @Suppress("UnsafeCastFromDynamic") private fun checkResizablEventHandler() { if (isResizable) { - isResizeEvent = true - KVManager.setResizeEvent(this) { - if (!isResizing) { + if (!isResizeEvent) { + isResizeEvent = true + KVManager.setResizeEvent(this) { val eid = getElementJQuery()?.attr("id") if (eid == id) { - val intWidth = (getElementJQuery()?.width()?.toInt() ?: 0) + 2 - val intHeight = (getElementJQuery()?.height()?.toInt() ?: 0) + 2 - isResizing = true - width = intWidth.px - height = intHeight.px - isResizing = false - content.width = (intWidth - 2).px - content.height = (intHeight - WINDOW_HEADER_HEIGHT - WINDOW_CONTENT_MARGIN_BOTTOM - 2).px + val outerWidth = (getElementJQuery()?.outerWidth()?.toInt() ?: 0) + val outerHeight = (getElementJQuery()?.outerHeight()?.toInt() ?: 0) + val intWidth = (getElementJQuery()?.width()?.toInt() ?: 0) + val intHeight = (getElementJQuery()?.height()?.toInt() ?: 0) + content.width = intWidth.px + content.height = (intHeight - WINDOW_HEADER_HEIGHT - WINDOW_CONTENT_MARGIN_BOTTOM).px + width = outerWidth.px + height = outerHeight.px this.dispatchEvent("resizeWindow", obj { detail = obj { - this.width = intWidth - this.height = intHeight + this.width = outerWidth + this.height = outerHeight } }) } |