0

I got a page where is checking if the user left the fullscreen. I want to delete/destroy this event watcher but could not find out how i can do this on the description API Description Here is my code:

  //create black background and disable scrolling
  $rootScope.fullScreen = !$rootScope.fullScreen;

  //make div fullScreen (Browser Native)
  if($rootScope.fullScreen == true) {
    var videoWindow = document.getElementById("full-screen");
    if (videoWindow.requestFullscreen) {
      videoWindow.requestFullscreen();
    }

      //check if user has closed fullscreen
      document.onwebkitfullscreenchange = function ( event ) {
        if(!document.webkitFullscreenElement) {
          $rootScope.fullScreen = false;
          //REMOVE THE EVENTHANDLER - STOP WATCHING!
          ?????????

        }
      };
elpeyotl
  • 372
  • 1
  • 3
  • 14

1 Answers1

1

What is your intention on removing the event?

document.onwebkitfullscreenchange = null;

should work.

M.Go
  • 69
  • 3
  • I want to remove it when the user closed the fullscreen window. There is no need to keep watching this event. It is part of a bigger angular app so I want to keep it clean. Your simple solution WORKED! Very simple! Thx! – elpeyotl Sep 27 '17 at 14:13