react-native-orientation-director 2.6.3 → 2.6.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -36,6 +36,9 @@ class OrientationDirectorModuleImpl internal constructor(private val context: Re
|
|
|
36
36
|
checkInterfaceOrientation(false)
|
|
37
37
|
}
|
|
38
38
|
|
|
39
|
+
// NOTE(1.init): This is needed to compute the initial device orientation
|
|
40
|
+
mOrientationSensorsEventListener.enable()
|
|
41
|
+
|
|
39
42
|
context.addLifecycleEventListener(mLifecycleListener)
|
|
40
43
|
mLifecycleListener.setOnHostResumeCallback {
|
|
41
44
|
if (!didComputeInitialDeviceOrientation || areOrientationSensorsEnabled) {
|
|
@@ -45,17 +48,17 @@ class OrientationDirectorModuleImpl internal constructor(private val context: Re
|
|
|
45
48
|
mBroadcastReceiver.register()
|
|
46
49
|
}
|
|
47
50
|
mLifecycleListener.setOnHostPauseCallback {
|
|
48
|
-
if (
|
|
51
|
+
if (!didComputeInitialDeviceOrientation || areOrientationSensorsEnabled) {
|
|
49
52
|
mOrientationSensorsEventListener.disable()
|
|
50
|
-
mAutoRotationObserver.disable()
|
|
51
53
|
}
|
|
54
|
+
mAutoRotationObserver.disable()
|
|
52
55
|
mBroadcastReceiver.unregister()
|
|
53
56
|
}
|
|
54
57
|
mLifecycleListener.setOnHostDestroyCallback {
|
|
55
|
-
if (areOrientationSensorsEnabled) {
|
|
58
|
+
if (!didComputeInitialDeviceOrientation || areOrientationSensorsEnabled) {
|
|
56
59
|
mOrientationSensorsEventListener.disable()
|
|
57
|
-
mAutoRotationObserver.disable()
|
|
58
60
|
}
|
|
61
|
+
mAutoRotationObserver.disable()
|
|
59
62
|
mBroadcastReceiver.unregister()
|
|
60
63
|
}
|
|
61
64
|
|
|
@@ -163,8 +166,14 @@ class OrientationDirectorModuleImpl internal constructor(private val context: Re
|
|
|
163
166
|
|
|
164
167
|
checkInterfaceOrientation()
|
|
165
168
|
|
|
166
|
-
|
|
167
|
-
|
|
169
|
+
// NOTE(2.init): This is needed to disable sensors if they were needed just for the initial
|
|
170
|
+
// device computation.
|
|
171
|
+
if (didComputeInitialDeviceOrientation) {
|
|
172
|
+
return
|
|
173
|
+
}
|
|
174
|
+
didComputeInitialDeviceOrientation = true
|
|
175
|
+
|
|
176
|
+
if (!areOrientationSensorsEnabled) {
|
|
168
177
|
mOrientationSensorsEventListener.disable()
|
|
169
178
|
}
|
|
170
179
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "react-native-orientation-director",
|
|
3
|
-
"version": "2.6.
|
|
3
|
+
"version": "2.6.5",
|
|
4
4
|
"description": "A Modern React Native library that allows you to access orientation",
|
|
5
5
|
"main": "./lib/module/index.js",
|
|
6
6
|
"types": "./lib/typescript/module/src/index.d.ts",
|