-
Notifications
You must be signed in to change notification settings - Fork 609
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
bug(@capacitor/screen-orientation): iOS landscape lock using incorrect mappings #2022
Comments
Tracking in #2039 |
This is not completed and the linked ticket does not describe the same problem. |
Ah I see now what you mean. Okay I'm going to reopen this and add it as a bug. |
This issue has been labeled as |
@IT-MikeS Is there any eta for when my pr can get looked at, merged and released? |
I believe its being looked at now |
Looks like my Pr has been merged into the 5.x branch! Thank you @IT-MikeS |
No, there will be a release as soon as the thumbs up is given, normally we wait until there are a few fixes in making the release more impactful rather than constant small releases. Expect to see it I'd say within a week but don't quote me on that. However if you look at the Versions tab on NPM (https://www.npmjs.com/package/@capacitor/screen-orientation?activeTab=versions) you can see there is a nightly, this will have the fixes in it, and may help get you unblocked for development but I don't recommend using it in production |
Thanks for the issue! This issue is being locked to prevent comments that are not relevant to the original issue. If this is still an issue with the latest version of the plugin, please create a new issue and ensure the template is fully filled out. |
Bug Report
Plugin(s)
@capacitor/[email protected]
Capacitor Version
Platform(s)
Current Behavior
Expected Behavior
Code Reproduction
I verified that this is also an issue in the repo https://github.com/WIStudent/capacitor-screen-orientation-issue-reproduction-app made by @WIStudent
Other Technical Details
iOS 14.5
After the screen is locked to the current orientation and the screen rotates 180 degrees, if you query for the current location again, it still shows that the current orientation is NOT THE SAME as the original.
iOS 16.2 & 17.1
After the screen is locked to the current orientation and the screen rotates 180 degrees, if you query for the current location again, it still shows that the current orientation is THE SAME as the original.
What is the issue
Issue lies in the difference between
LandscapeLeft
andLandscapeRight
inUIDeviceOrientation
andUIInterfaceOrientation
UIDeviceOrientation.landscapeLeft
is NOT the same asUIInterfaceOrientation.landscapeLeft
UIDeviceOrientation.landscapeRight
is NOT the same asUIInterfaceOrientation.landscapeRight
In UIDeviceOrientation, the focus for left and right is based on the position of the camera, while in UIInterfaceOrientation, the focus for left and right is based on the position of the home button. Both of which, camera and home button, are on opposite sides of the phone.
How to fix
Either:
Change mappings in
fromOrientationTypeToMask
andfromOrientationTypeToInt
so thatlandscape-primary
maps toUIInterfaceOrientationMask.landscapeRight
andUIInterfaceOrientation.landscapeRight.rawValue
respectfullylandscape-secondary
maps toUIInterfaceOrientationMask.landscapeLeft
andUIInterfaceOrientation.landscapeLeft.rawValue
respectfullyChange mapping in
fromDeviceOrientationToOrientationType
so thatUIDeviceOrientation.landscapeRight
maps tolandscape-primary
UIDeviceOrientation.landscapeLeft
maps tolandscape-secondary
1. IS PREFERRED because it will align the
landscape-primary
value on iOS and Android devices by having the camera/top of the device on the left, and the home button/bottom of the device on the right. Currently they are in sync on both devices when retrieving current orientation, but not when locking to a specific landscape orientation.The text was updated successfully, but these errors were encountered: