ui: Avoid using eval

This commit is contained in:
Hajime Hoshi 2018-07-14 23:47:31 +09:00
parent e25c237a01
commit 09c93ac86d

View File

@ -54,7 +54,7 @@ var (
window = js.Global().Get("window") window = js.Global().Get("window")
document = js.Global().Get("document") document = js.Global().Get("document")
requestAnimationFrame = window.Get("requestAnimationFrame") requestAnimationFrame = window.Get("requestAnimationFrame")
setTimeoutForLoop = js.Global().Call("eval", "((f) => { setTimeout(f, 0); })") setTimeout = window.Get("setTimeout")
) )
func MonitorSize() (int, int) { func MonitorSize() (int, int) {
@ -229,7 +229,7 @@ func (u *userInterface) loop(g GraphicsContext) error {
if u.vsync { if u.vsync {
requestAnimationFrame.Invoke(cf) requestAnimationFrame.Invoke(cf)
} else { } else {
setTimeoutForLoop.Invoke(cf) setTimeout.Invoke(cf, 0)
} }
} }
cf = js.NewCallback(f) cf = js.NewCallback(f)