sindresorhus / screenfull

Simple wrapper for cross-browser usage of the JavaScript Fullscreen API
https://sindresorhus.com/screenfull
MIT License
7.06k stars 698 forks source link

screenfull.isFullscreen returns true when exiting fullscreen #12

Closed wiemann closed 11 years ago

wiemann commented 12 years ago

screenfull.isFullscreen doesn't return false when called in onchange event after exiting fullscreen

Go to the example page http://sindresorhus.com/screenfull.js/

Add this event binding in the JS console: screenfull.onchange = function(){console.log( 'Am I fullscreen? ' + screenfull.isFullscreen ? 'Yes' : 'No' );};

And now enter and exit fullscreen mode. On exit it will also return that screenfull.isFullscreen is true (Yes). How can one make it return the proper value?

sindresorhus commented 11 years ago

It does, you need to wrap your expression in parens:

screenfull.onchange = function(){
    console.log('Am I fullscreen? ' + (screenfull.isFullscreen ? 'Yes' : 'No') );
};