Tymski Posted July 27, 2017 Share Posted July 27, 2017 I want to make a fullscreen button inside the stage. I added on pointerdown to a PIXI.Sprite like this: fullscreenbutton.on('pointerdown', function(e){ fullscreen(); } On my Android device I get: Quote Failed to execute 'requestFullscreen' on 'Element': API can only be initiated by a user gesture. The same function works just fine on <button onclick="fullscreen">Full Screen!</button> Is it possible to somehow register pointerdown on PIXI.Sprite as user gesture? Or do I have to position-absolute the HTML button on top of canvas and there is no other way? Quote Link to comment Share on other sites More sharing options...
themoonrat Posted July 27, 2017 Share Posted July 27, 2017 Despite adding support for pointer events in the latest Chrome... they haven't made them act as a user event that can unlock other apis, like webaudio and fullscreen. To unlock these APIs, you'll need to explicitly use 'touchstart' Quote Link to comment Share on other sites More sharing options...
Tymski Posted July 27, 2017 Author Share Posted July 27, 2017 1 hour ago, themoonrat said: Despite adding support for pointer events in the latest Chrome... they haven't made them act as a user event that can unlock other apis, like webaudio and fullscreen. To unlock these APIs, you'll need to explicitly use 'touchstart' Tried that and it didn't work. I doesn't even work when I add touchstart event listener to a button. Quote Link to comment Share on other sites More sharing options...
themoonrat Posted July 27, 2017 Share Posted July 27, 2017 Try fullscreenbutton.on('click', function(e){ fullscreen(); } Looked at my code for this and indeed it seems click is the only event that works for full screen api across android and windows phones. Well, actually, my code sets up listeners for both touchend and click, but not sure if that was overkill on my part or attempting to pre-empt a future browser manufacturer decision! Quote Link to comment Share on other sites More sharing options...
Tymski Posted July 28, 2017 Author Share Posted July 28, 2017 That doesn't work since there is no "click" event happening when I "touch" the sprite. wow: it works on touchend. what the heck? Quote Link to comment Share on other sites More sharing options...
themoonrat Posted July 28, 2017 Share Posted July 28, 2017 So the rational behind the browser vendors is that a touchstart could be the start of scrolling the page, rather than interacting on screen. They want certain api's to be unlocked on a guaranteed 'user has touched the screen for the sake of trying to press something'. By using 'touchend', what they can do is only unlock the api if there is a touchstart following by a touchend. If there is a touchstart, then some scrolling, then a touchend, then they know not to unlock the api's on the touchend; the user was scrolling, not interacting. (Apple changing unlocking audio from touchstart to touchend from ios9 to ios10 caused us to have to re-release all of our games to get sound working again. grrrrrr) Quote Link to comment Share on other sites More sharing options...
Tymski Posted August 7, 2017 Author Share Posted August 7, 2017 sounds reasonable Quote Link to comment Share on other sites More sharing options...
Flood-Games Posted April 11, 2023 Share Posted April 11, 2023 pointerup event does work for fullscreen API. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.