Skip to content

Commit

Permalink
v0.0.13
Browse files Browse the repository at this point in the history
  • Loading branch information
dimkauzh committed Oct 15, 2023
1 parent 9bd7b6e commit 351b98e
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/backend/document/document.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,14 @@ func (d *documentElement) ClientHeight() js.Value {
return js.Global().Get("document").Get("documentElement").Get("clientHeight")
}

func (d *documentElement) ClientIntWidth() int {
return js.Global().Get("document").Get("documentElement").Get("clientWidth").Int()
}

func (d *documentElement) ClientIntHeight() int {
return js.Global().Get("document").Get("documentElement").Get("clientHeight").Int()
}

func (d *styleDocument) Set(key string, value interface{}) {
js.Global().Get("document").Get("documentElement").Get("style").Set(key, value)
}
Expand Down
25 changes: 25 additions & 0 deletions src/webzen/init.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,32 @@ func Init() {
keys.SetupEventListeners()
}

func CustomInit(width, height int) {
canvas := document.GetElementById("webzen")
if canvas.IsNull() {
canvas = document.CreateCanvasElement()
canvas.Set("id", "canvas")
document.Body.AppendCanvasChild(canvas)
}

canvas.Set("width", width)
canvas.Set("height", height)

document.DocumentElement.Style.Set("overflow", "hidden")
document.Body.Style.Set("overflow", "hidden")

keys.SetupEventListeners()
}

func Update() {
time.Sleep(time.Millisecond * 16)
clearCanvas()
}

func GetWidth() int {
return document.DocumentElement.ClientIntWidth()
}

func GetHeight() int {
return document.DocumentElement.ClientIntHeight()
}

0 comments on commit 351b98e

Please sign in to comment.