Jump to content

pointerdown on PIXI object isn't recognized as user gesture


Recommended Posts

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){

On my Android device I get:


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?

Link to comment
Share on other sites

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.

Link to comment
Share on other sites


fullscreenbutton.on('click', function(e){

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! 


Link to comment
Share on other sites

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)

Link to comment
Share on other sites

  • 2 weeks later...
  • 5 years later...

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.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


  • Recently Browsing   0 members

    • No registered users viewing this page.
  • Create New...