visibilityjs icon indicating copy to clipboard operation
visibilityjs copied to clipboard

how to not call visibility if i made fullscreen

Open novaknole opened this issue 5 years ago • 5 comments

So in my app, I have games and when I click play , what I do is call fullscreen code which starts the game in fullscreen mode.

Somewhere in my app, I have this piece of code:

this.visibility = Visibility.change((event, state) => {
                            switch (state) {
                                case 'visible':
                                    break;
                                case 'hidden':
                                    console.log("coming here ? ");
                                    break;
                            }
                        });

Now, this works fine for all cases except fullscreen. The thing I want is when fullscreen gets activated, I don't want it to call console.log("coming here ?"). I don't want it to do anything. Is this possible?

novaknole avatar Apr 21 '20 12:04 novaknole

You do not need Visibility.js nowadays. Use standard API without extra library wrapper.

ai avatar Apr 21 '20 13:04 ai

  • So, what you're saying is i don't have to use this library at all to do what I want?
  • Which one is the standard API? any link?

novaknole avatar Apr 21 '20 13:04 novaknole

https://developer.mozilla.org/en-US/docs/Web/API/Page_Visibility_API

ai avatar Apr 21 '20 13:04 ai

do you do anything in this wrapper so that it helps to work it out for more browser versions that it's currently supported on that link you linked?

novaknole avatar Apr 21 '20 13:04 novaknole

Most modern browsers support Page Visibility API out of the box https://caniuse.com/#feat=mdn-api_document_onvisibilitychange

ai avatar Apr 21 '20 14:04 ai