Skip to content
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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(@capacitor/screen-orientation): Orientation 'landscape' lock should use current held landscape if any #2039

Open
codepip55 opened this issue Feb 23, 2024 · 9 comments
Labels
platform: android platform: ios type: feature request A new feature, enhancement, or improvement

Comments

@codepip55
Copy link

Bug Report

Plugin(s)

@capacitor/screen-orientation 5.0.7

Capacitor Version

馃拪   Capacitor Doctor  馃拪 

Latest Dependencies:

  @capacitor/cli: 5.7.0
  @capacitor/core: 5.7.0
  @capacitor/android: 5.7.0
  @capacitor/ios: 5.7.0

Installed Dependencies:

  @capacitor/cli: 5.6.0
  @capacitor/android: 5.7.0
  @capacitor/core: 5.7.0
  @capacitor/ios: 5.7.0

Platform(s)

Android and iOS

Current Behavior

When locking the screen orientation to 'landscape' it locks it to landscape left. Meaning that if I'm holding my phone in landscape right mode, the view rotates 180 degrees and locks there. (Same goes for android with landscape and landscape reverse).

You can see this is how its configured in the plugin code:
iOS:


Android:

Expected Behavior

If the phone is physically held in either landscape left or right (normal or reverse for android), when locking the orientation to 'landscape' it should lock the current orientation without rotating anything.

Code Reproduction

This simple app by WIStudent reproduces the problem: https://github.com/WIStudent/capacitor-screen-orientation-issue-reproduction-app/tree/main

Other Technical Details

Additional Context

@ionitron-bot ionitron-bot bot added the triage label Feb 23, 2024
@ionitron-bot ionitron-bot bot removed the triage label Feb 23, 2024
@IT-MikeS IT-MikeS self-assigned this Feb 23, 2024
@IT-MikeS IT-MikeS changed the title @capacitor/screen-orientation - Bug: Orientation 'landscape' and rotating the phone 180 degrees does not rotate the view @capacitor/screen-orientation - Feature Request: Orientation 'landscape' lock should use current held landscape if any Feb 23, 2024
@IT-MikeS IT-MikeS added the type: feature request A new feature, enhancement, or improvement label Feb 23, 2024
@IT-MikeS
Copy link
Contributor

Updating the issue as a feature request as you can achieve explicit "landscape right" by using the landscape-secondary option.

@IT-MikeS IT-MikeS removed their assignment Feb 23, 2024
@IT-MikeS IT-MikeS changed the title @capacitor/screen-orientation - Feature Request: Orientation 'landscape' lock should use current held landscape if any feat(@capacitor/screen-orientation): Orientation 'landscape' lock should use current held landscape if any Feb 23, 2024
@brian-weasner
Copy link
Contributor

@IT-MikeS This issue and #2022 are similar but not the same.

iOS is broken on lock, not just when locking to 'landscape' because the Landscape Values returned by different native level functions are from different objects and are NOT equivalent.

@codepip55
Copy link
Author

@IT-MikeS To clarify, the issue is not that the app cant be locked to "landscape right", its that the "landscape" option in the plugin is defined as just "landscape left" instead of both "landscape left" and "landscape right".

@IT-MikeS
Copy link
Contributor

@IT-MikeS To clarify, the issue is not that the app cant be locked to "landscape right", its that the "landscape" option in the plugin is defined as just "landscape left" instead of both "landscape left" and "landscape right".

Understood, Im going to leave it as a feature request as it changes current behaviour of the plugin, however I agree that landscape option should respect the current rotation the device is in when being locked.

@brian-weasner
Copy link
Contributor

This issue would be resolved by making a separate case statement for "landscape" here:

And returning UIInterfaceOrientationMask.landscape

@codepip55
Copy link
Author

For Android I would suggest using SCREEN_ORIENTATION_SENSOR_LANDSCAPE (https://stackoverflow.com/a/35669103/16687547).

@codepip55
Copy link
Author

Me and my colleague created a fix for this issue

@ericmulder
Copy link

Hi all, any idea when this pull request will be reviewed?

@jansgescheit
Copy link

This is an essential function. is anything else happening here?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
platform: android platform: ios type: feature request A new feature, enhancement, or improvement
Projects
None yet
Development

No branches or pull requests

6 participants