Skip to content

Orientation not working properly in Safari on iOS 16 #367

Open
@samuelsimoes

Description

@samuelsimoes

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.

To fix this, I suggest moving the iOS-specific code block

current-device/src/index.js

Lines 181 to 186 in af95870

if (
device.ios() &&
Object.prototype.hasOwnProperty.call(window, 'orientation')
) {
return Math.abs(window.orientation) === 90
}
to the top of the general detection routine. This way, iOS will always use window.orientation, which continues to work as expected.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bug-majorBugs that are affecting production users.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions