📱 The easiest way to write conditional CSS and/or JavaScript based on device operating system (iOS, Android, Blackberry, Windows, Firefox OS, MeeGo), orientation (Portrait vs. Landscape), and type (Tablet vs. Mobile).
Safari on iOS 16 exposes the screen.orientation property now, but from what I've seen, it only returns the correct information after the screen rotation animation has finished. However, the orientationchange event is invoked as soon as the animation starts, causing an issue with detecting the current orientation, as it always returns the previous orientation instead.
Safari on iOS 16 exposes the
screen.orientation
property now, but from what I've seen, it only returns the correct information after the screen rotation animation has finished. However, theorientationchange
event is invoked as soon as the animation starts, causing an issue with detecting the current orientation, as it always returns the previous orientation instead.To fix this, I suggest moving the iOS-specific code block https://github.com/matthewhudson/current-device/blob/af958702564c904b66d666ab95ce37175627af92/src/index.js#L181-L186 to the top of the general detection routine. This way, iOS will always use
window.orientation
, which continues to work as expected.