internal/uidriver/js: Bug fix: SetFullscreen didn't work on Safari

Updates #1611
This commit is contained in:
Hajime Hoshi 2021-04-28 23:28:55 +09:00
parent 5d3a76cbe6
commit b509ce523d

View File

@ -102,7 +102,6 @@ func (u *UserInterface) SetFullscreen(fullscreen bool) {
f := canvas.Get("requestFullscreen") f := canvas.Get("requestFullscreen")
if !f.Truthy() { if !f.Truthy() {
f = canvas.Get("webkitRequestFullscreen") f = canvas.Get("webkitRequestFullscreen")
return
} }
f.Call("bind", canvas).Invoke() f.Call("bind", canvas).Invoke()
return return
@ -422,11 +421,15 @@ func init() {
return nil return nil
})) }))
document.Call("addEventListener", "pointerlockerror", js.FuncOf(func(this js.Value, args []js.Value) interface{} { document.Call("addEventListener", "pointerlockerror", js.FuncOf(func(this js.Value, args []js.Value) interface{} {
js.Global().Get("console").Call("error", "pointerlockerror event is fired. 'sandbox=\"allow-pointer-lock\"' might be required. There is a known issue on Safari (hajimehoshi/ebiten#1604)") js.Global().Get("console").Call("error", "pointerlockerror event is fired. 'sandbox=\"allow-pointer-lock\"' might be required at an iframe. This function on browsers must be called as a result of a gestural interaction or orientation change.")
return nil return nil
})) }))
document.Call("addEventListener", "fullscreenerror", js.FuncOf(func(this js.Value, args []js.Value) interface{} { document.Call("addEventListener", "fullscreenerror", js.FuncOf(func(this js.Value, args []js.Value) interface{} {
js.Global().Get("console").Call("error", "fullscreenerror event is fired. This function on browsers must be called as a result of a gestural interaction or orientation change.") js.Global().Get("console").Call("error", "fullscreenerror event is fired. 'sandbox=\"fullscreen\"' might be required at an iframe. This function on browsers must be called as a result of a gestural interaction or orientation change.")
return nil
}))
document.Call("addEventListener", "webkitfullscreenerror", js.FuncOf(func(this js.Value, args []js.Value) interface{} {
js.Global().Get("console").Call("error", "webkitfullscreenerror event is fired. 'sandbox=\"fullscreen\"' might be required at an iframe. This function on browsers must be called as a result of a gestural interaction or orientation change.")
return nil return nil
})) }))
} }