Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion platform/web/web.go
Original file line number Diff line number Diff line change
Expand Up @@ -238,6 +238,11 @@ func (p *Platform) registerEventListeners(cb platform.Callbacks) {
if w <= 0 || h <= 0 {
return
}
dpr := p.window.Get("devicePixelRatio").Float()
if dpr < 1 {
dpr = 1
}
p.dpr = dpr
p.width = w
p.height = h
p.fbWidth = int(float64(w) * p.dpr)
Expand Down Expand Up @@ -265,7 +270,9 @@ func (p *Platform) addEventListener(target js.Value, event string, handler func(
}

func (p *Platform) canvasPos(e js.Value) (float32, float32) {
return float32(e.Get("offsetX").Float()), float32(e.Get("offsetY").Float())
x := e.Get("offsetX").Float() * p.dpr
y := e.Get("offsetY").Float() * p.dpr
return float32(x), float32(y)
}

func (p *Platform) Destroy() {
Expand Down
Loading