Skip to content

Commit 144e7dd

Browse files
Update main.kt
1 parent d39e6aa commit 144e7dd

File tree

1 file changed

+3
-6
lines changed
  • composeApp/src/wasmJsMain/kotlin/com/krossovochkin/chesskt

1 file changed

+3
-6
lines changed

composeApp/src/wasmJsMain/kotlin/com/krossovochkin/chesskt/main.kt

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ import kotlinx.browser.window
99
import kotlin.math.min
1010
import org.jetbrains.compose.resources.ExperimentalResourceApi
1111
import org.w3c.dom.HTMLElement
12-
import org.w3c.dom.Element
1312

1413
@OptIn(ExperimentalComposeUiApi::class, ExperimentalResourceApi::class)
1514
fun main() {
@@ -25,15 +24,13 @@ fun main() {
2524
}
2625

2726
private fun getContainerSize(): Int? {
28-
val windowWithFrame = js("window") as WindowWithFrameElement
29-
val iframe = windowWithFrame.frameElement as? HTMLElement
27+
val iframe = rawWindow.frameElement as? HTMLElement
3028
return if (iframe != null) {
3129
min(iframe.offsetWidth, iframe.offsetHeight)
3230
} else {
3331
min(window.innerWidth, window.innerHeight)
3432
}.takeIf { it > 0 }
3533
}
3634

37-
external interface WindowWithFrameElement {
38-
val frameElement: Element?
39-
}
35+
@JsName("window")
36+
external val rawWindow: dynamic

0 commit comments

Comments
 (0)