ui: Simplify vsync

This commit is contained in:
Hajime Hoshi 2016-08-28 17:09:58 +09:00
parent 6c3af3a9dc
commit cddaae55dd

View File

@ -48,19 +48,11 @@ func shown() bool {
func vsync() { func vsync() {
ch := make(chan struct{}) ch := make(chan struct{})
n := 1 js.Global.Get("window").Call("requestAnimationFrame", func() {
var l func() // TODO: In iOS8, this is called at every 1/30[sec] frame.
l = func() { // Can we use DOMHighResTimeStamp?
if 0 < n {
n--
// TODO: In iOS8, this is called at every 1/30[sec] frame.
// Can we use DOMHighResTimeStamp?
js.Global.Get("window").Call("requestAnimationFrame", l)
return
}
close(ch) close(ch)
} })
l()
<-ch <-ch
} }