Skip to content

Commit

Permalink
docs: better handling for not supported
Browse files Browse the repository at this point in the history
  • Loading branch information
marcoscaceres committed Aug 9, 2023
1 parent cdac12c commit 7534ec9
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions demo/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -157,12 +157,16 @@ <h1>Screen Orientation Lock API Demo</h1>
renderUpdate();
};

// use a media query to detect orientation change
if (!screen.orientation) {
if (screen.orientation) {
log("Using screen.orientation to handle events.");
screen.orientation?.addEventListener("change", handleOrientationChange);
} else if("onorientationchange" in window) {
log("Using legacy window's orientationchange to handle events.");
window.addEventListener("orientationchange", handleOrientationChange);
} else {
log("Using media query to handle orientation changes.");
const orientationQuery = window.matchMedia("(orientation: landscape)");
orientationQuery.addEventListener("change", handleOrientationChange);
} else {
screen.orientation?.addEventListener("change", handleOrientationChange);
}

document.addEventListener("fullscreenchange", handleFullscreen);
Expand Down

0 comments on commit 7534ec9

Please sign in to comment.