Skip to content

Commit ea6c5b9

Browse files
committed
feat: increase pitch tolerance and rename tolerance to rollTolerance
1 parent 6f57dcb commit ea6c5b9

1 file changed

Lines changed: 4 additions & 4 deletions

File tree

  • android/src/main/java/com/orientationdirector/implementation

android/src/main/java/com/orientationdirector/implementation/Utils.kt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,8 @@ class Utils(private val context: ReactContext) {
2626
val rollDegrees = Math.toDegrees(rollRadians.toDouble()).toFloat()
2727

2828
// This is needed to account for inaccuracy due to subtle movements such as tilting
29-
val pitchTolerance = 5f
30-
val tolerance = 20f
29+
val pitchTolerance = 15f
30+
val rollTolerance = 20f
3131

3232
//////////////////////////////////////
3333
// These limits are set based on SensorManager.getOrientation reference
@@ -44,8 +44,8 @@ class Utils(private val context: ReactContext) {
4444
return when {
4545
rollDegrees.equals(-0f) && (pitchDegrees.equals(0f) || pitchDegrees.equals(-0f)) -> Orientation.FACE_UP
4646
rollDegrees.equals(-180f) && (pitchDegrees.equals(0f) || pitchDegrees.equals(-0f)) -> Orientation.FACE_DOWN
47-
rollDegrees in tolerance..landscapeRightLimit - tolerance && isPitchInLandscapeModeRange -> Orientation.LANDSCAPE_RIGHT
48-
rollDegrees in landscapeLeftLimit + tolerance..-tolerance && isPitchInLandscapeModeRange -> Orientation.LANDSCAPE_LEFT
47+
rollDegrees in rollTolerance..landscapeRightLimit - rollTolerance && isPitchInLandscapeModeRange -> Orientation.LANDSCAPE_RIGHT
48+
rollDegrees in landscapeLeftLimit + rollTolerance..-rollTolerance && isPitchInLandscapeModeRange -> Orientation.LANDSCAPE_LEFT
4949
pitchDegrees in portraitLimit..pitchTolerance -> Orientation.PORTRAIT
5050
else -> Orientation.PORTRAIT_UPSIDE_DOWN
5151
}

0 commit comments

Comments
 (0)