React-native-orientation: Different behaviour for locking in iOS and Android

Created on 23 May 2018  路  1Comment  路  Source: yamill/react-native-orientation

First off; thanks for a great library. Used it on more than one occasion already :)

On our current project i'm running into an issue with the lockToPortrait() etc methods where the behavior is different on iOS and Android. Currently on iOS after locking the device to a certain orientation it also sends a orientation change notification. On Android however it just locks and does not send this event. This can lead to issues if your user turns the device to landscape and then opens the component that locks or unlocks the device.

Our use case:

  1. app is locked to portrait
  2. user turns device to landscape and then
  3. user opens image modal which unlocks orientations
  4. user closes image modal (which locks device back to portrait)
  5. the lock fires event that says device is in portrait (even though it's still in landscape)
  6. user opens image modal again; which is now oriented in portrait incorrectly

My current solution (1) is to change the behavior in iOS so that the orientation event after the locking becomes optional. But i think that the default behavior should actually be the same across iOS and Android.

Would you accept a PR that implements this? It would most likely change behavior that is now depended upon by package users so i would understand if you would not like to change this now known exception.

(1) https://bitbucket.org/rubikopensource/react-native-orientation/commits/80cbd3bda1409cb24e05c28699b945bfce5c9492?at=locks-without-events

Most helpful comment

>All comments

Was this page helpful?
0 / 5 - 0 ratings