@capgo/capacitor-screen-orientation 8.1.9 → 8.1.10
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.
|
@@ -17,7 +17,7 @@ import com.getcapacitor.annotation.CapacitorPlugin;
|
|
|
17
17
|
@CapacitorPlugin(name = "CapacitorScreenOrientation")
|
|
18
18
|
public class CapacitorScreenOrientationPlugin extends Plugin implements SensorEventListener {
|
|
19
19
|
|
|
20
|
-
private final String pluginVersion = "8.1.
|
|
20
|
+
private final String pluginVersion = "8.1.10";
|
|
21
21
|
private int currentOrientation;
|
|
22
22
|
private SensorManager sensorManager;
|
|
23
23
|
private Sensor accelerometer;
|
|
@@ -258,25 +258,13 @@ public class CapacitorScreenOrientationPlugin extends Plugin implements SensorEv
|
|
|
258
258
|
// X axis: left/right tilt
|
|
259
259
|
// Y axis: forward/backward tilt
|
|
260
260
|
// Z axis: up/down (gravity when flat)
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
} else {
|
|
268
|
-
// Portrait orientation
|
|
269
|
-
return y > 0 ? "portrait-secondary" : "portrait-primary";
|
|
270
|
-
}
|
|
271
|
-
} else {
|
|
272
|
-
// Device is tilted, use strongest axis
|
|
273
|
-
if (Math.abs(x) > threshold && Math.abs(x) > Math.abs(y)) {
|
|
274
|
-
return x > 0 ? "landscape-secondary" : "landscape-primary";
|
|
275
|
-
} else if (Math.abs(y) > threshold) {
|
|
276
|
-
return y > 0 ? "portrait-secondary" : "portrait-primary";
|
|
277
|
-
}
|
|
261
|
+
if (Math.abs(x) > threshold && Math.abs(x) > Math.abs(y)) {
|
|
262
|
+
// Landscape orientation
|
|
263
|
+
return x > 0 ? "landscape-secondary" : "landscape-primary";
|
|
264
|
+
} else if (Math.abs(y) > threshold) {
|
|
265
|
+
// Portrait orientation
|
|
266
|
+
return y > 0 ? "portrait-secondary" : "portrait-primary";
|
|
278
267
|
}
|
|
279
|
-
|
|
280
268
|
// Default to current if unclear
|
|
281
269
|
return currentPhysicalOrientation;
|
|
282
270
|
}
|
|
@@ -11,7 +11,7 @@ import UIKit
|
|
|
11
11
|
*/
|
|
12
12
|
@objc(CapacitorScreenOrientationPlugin)
|
|
13
13
|
public class CapacitorScreenOrientationPlugin: CAPPlugin, CAPBridgedPlugin {
|
|
14
|
-
private let pluginVersion: String = "8.1.
|
|
14
|
+
private let pluginVersion: String = "8.1.10"
|
|
15
15
|
public let identifier = "CapacitorScreenOrientationPlugin"
|
|
16
16
|
public let jsName = "CapacitorScreenOrientation"
|
|
17
17
|
public let pluginMethods: [CAPPluginMethod] = [
|
|
@@ -52,7 +52,7 @@ public class CapacitorScreenOrientationPlugin: CAPPlugin, CAPBridgedPlugin {
|
|
|
52
52
|
// Skip system orientation changes when motion tracking is active
|
|
53
53
|
// to avoid duplicate events
|
|
54
54
|
guard !isTrackingWithMotion else { return }
|
|
55
|
-
|
|
55
|
+
|
|
56
56
|
let orientation = UIDevice.current.orientation
|
|
57
57
|
if orientation.isValidInterfaceOrientation {
|
|
58
58
|
notifyOrientationChange(fromDeviceOrientation: orientation)
|
package/package.json
CHANGED