From 7534ec9ef743b95ed0dc055d8cd9157c2999ab2b Mon Sep 17 00:00:00 2001 From: Marcos Caceres Date: Wed, 9 Aug 2023 17:25:45 +1000 Subject: [PATCH] docs: better handling for not supported --- demo/index.html | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/demo/index.html b/demo/index.html index c100146..f637eea 100644 --- a/demo/index.html +++ b/demo/index.html @@ -157,12 +157,16 @@

Screen Orientation Lock API Demo

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);