Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Detect Fullscreenmode #1

Closed
patlux opened this issue Jul 15, 2015 · 5 comments
Closed

Detect Fullscreenmode #1

patlux opened this issue Jul 15, 2015 · 5 comments
Labels

Comments

@patlux
Copy link

patlux commented Jul 15, 2015

Hi,

what if I press F11 on my keyboard or activate the fullscreen mode over my browser manually, is there a function/event to detect this? Can you implement a functionality to this?

See: http://stackoverflow.com/questions/16755129/detect-fullscreen-mode

patlux

@hrajchert
Copy link
Owner

Well, I've tried it myself with no luck. I'm only wrapping the screenfull library, and they are only putting a thin layer on top of the HTML5 fullscreen API.

I've searched on the screenfull issue list, and it was listed as a bug that couldn't be fixed

sindresorhus/screenfull#82

It seemed strange that it couldn't be fixed, so I searched in the mozilla specs and other sites and found this:
http://stackoverflow.com/questions/21103478/fullscreenchange-event-not-firing-in-chrome

What it basically says is that they don't fire the event for security reasons :S...

Not much we can do about it.

@blitzmann
Copy link

We had a need to determine if the page was fullscreen or not by using both. At first, I tried $document.keyup(), which captures the keypress of F11 into fullscreen, but does not capture the keypress when exiting.

The solution that we came up with was to watch the window height:

    var w = angular.element($window);

    w.bind('resize', function () {
        $scope.$apply();
    });

    $scope.$watch(() => $window.innerHeight, function (value) {
          if (value == screen.height) {
              $scope.isFullScreen = true;
          } else {
              $scope.isFullScreen = false;
          }
      }, true);

Everytime the window resizes, we check to see if the height matches the screen height. If it does, we assume it's fullscreen. We don't check width, as I have the console docked to the side and that screws with the window size (console docked to the bottom will cause this to not work). It's definitely hacky and not a proper solution, but for every day users that aren't working in the console, this seems to work well.

@hrajchert
Copy link
Owner

Nice hack ;)... you can even make a directive or service out of that.

@bernardoadc
Copy link

What about just preventing the F11 effect, is it possible? This will force user to enable fullscreen some other way

@KimChonHo
Copy link

onresize = (event) => {
if (!window.screenTop && !window.screenY) console.log("full");
else console.log("win");
};

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

5 participants