-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add a module to handle the full-screen mode of the map container for …
…different desktop browsers
- Loading branch information
Showing
3 changed files
with
70 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
/* Copyright (c) 2023-2024 Serhii I. Myshko | ||
https://github.com/sergeiown/Map_with_Marker_Clusters/blob/main/LICENSE */ | ||
|
||
export function toggleFullScreen(element) { | ||
function handleFullScreenRequest(promise) { | ||
promise | ||
.then(() => { | ||
console.log('Entered full-screen mode.'); | ||
}) | ||
.catch((err) => { | ||
console.error(`Error attempting to enable full-screen mode: ${err.message} (${err.name})`); | ||
}); | ||
} | ||
|
||
function handleFullScreenExit(promise) { | ||
promise | ||
.then(() => { | ||
console.log('Exited full-screen mode.'); | ||
}) | ||
.catch((err) => { | ||
console.error(`Error attempting to disable full-screen mode: ${err.message} (${err.name})`); | ||
}); | ||
} | ||
|
||
if (!document.fullscreenElement) { | ||
if (element.requestFullscreen) { | ||
handleFullScreenRequest(element.requestFullscreen()); | ||
} else if (element.mozRequestFullScreen) { | ||
// Firefox | ||
handleFullScreenRequest(element.mozRequestFullScreen()); | ||
} else if (element.webkitRequestFullscreen) { | ||
// Chrome, Safari, and Opera | ||
handleFullScreenRequest(element.webkitRequestFullscreen()); | ||
} else if (element.msRequestFullscreen) { | ||
// IE/Edge | ||
handleFullScreenRequest(element.msRequestFullscreen()); | ||
} else { | ||
console.error('Fullscreen API is not supported by this browser.'); | ||
} | ||
} else { | ||
if (document.exitFullscreen) { | ||
handleFullScreenExit(document.exitFullscreen()); | ||
} else if (document.mozCancelFullScreen) { | ||
// Firefox | ||
handleFullScreenExit(document.mozCancelFullScreen()); | ||
} else if (document.webkitExitFullscreen) { | ||
// Chrome, Safari, and Opera | ||
handleFullScreenExit(document.webkitExitFullscreen()); | ||
} else if (document.msExitFullscreen) { | ||
// IE/Edge | ||
handleFullScreenExit(document.msExitFullscreen()); | ||
} else { | ||
console.error('Fullscreen API is not supported by this browser.'); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.