logo

mastofe

My custom branche(s) on git.pleroma.social/pleroma/mastofe git clone https://hacktivis.me/git/mastofe.git

fullscreen.js (1606B)


  1. // APIs for normalizing fullscreen operations. Note that Edge uses
  2. // the WebKit-prefixed APIs currently (as of Edge 16).
  3. export const isFullscreen = () => document.fullscreenElement ||
  4. document.webkitFullscreenElement ||
  5. document.mozFullScreenElement;
  6. export const exitFullscreen = () => {
  7. if (document.exitFullscreen) {
  8. document.exitFullscreen();
  9. } else if (document.webkitExitFullscreen) {
  10. document.webkitExitFullscreen();
  11. } else if (document.mozCancelFullScreen) {
  12. document.mozCancelFullScreen();
  13. }
  14. };
  15. export const requestFullscreen = el => {
  16. if (el.requestFullscreen) {
  17. el.requestFullscreen();
  18. } else if (el.webkitRequestFullscreen) {
  19. el.webkitRequestFullscreen();
  20. } else if (el.mozRequestFullScreen) {
  21. el.mozRequestFullScreen();
  22. }
  23. };
  24. export const attachFullscreenListener = (listener) => {
  25. if ('onfullscreenchange' in document) {
  26. document.addEventListener('fullscreenchange', listener);
  27. } else if ('onwebkitfullscreenchange' in document) {
  28. document.addEventListener('webkitfullscreenchange', listener);
  29. } else if ('onmozfullscreenchange' in document) {
  30. document.addEventListener('mozfullscreenchange', listener);
  31. }
  32. };
  33. export const detachFullscreenListener = (listener) => {
  34. if ('onfullscreenchange' in document) {
  35. document.removeEventListener('fullscreenchange', listener);
  36. } else if ('onwebkitfullscreenchange' in document) {
  37. document.removeEventListener('webkitfullscreenchange', listener);
  38. } else if ('onmozfullscreenchange' in document) {
  39. document.removeEventListener('mozfullscreenchange', listener);
  40. }
  41. };