1.1.7 • Published 3 years ago
@robingenz/capacitor-screen-orientation v1.1.7
Maintainers
| Maintainer | GitHub | Social |
|---|---|---|
| Robin Genz | robingenz | @robin_genz |
Installation
npm install @robingenz/capacitor-screen-orientation
npx cap synciOS
On iOS you must add the following to your app's AppDelegate.swift:
+ import RobingenzCapacitorScreenOrientation
@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate {
+ func application(_ application: UIApplication, supportedInterfaceOrientationsFor window: UIWindow?) -> UIInterfaceOrientationMask {
+ return ScreenOrientation.getSupportedInterfaceOrientations()
+ }Configuration
No configuration required for this plugin.
Demo
A working example can be found here: robingenz/capacitor-plugin-demo
Usage
import { ScreenOrientation } from '@robingenz/capacitor-screen-orientation';
const lock = async () => {
await ScreenOrientation.lock({ type: OrientationType.LANDSCAPE });
};
const unlock = async () => {
await ScreenOrientation.unlock();
};
const getCurrentOrientation = async () => {
const result = await ScreenOrientation.getCurrentOrientation();
return result.type;
};API
lock(...)
lock(options: LockOptions) => Promise<void>Locks the device orientation.
| Param | Type |
|---|---|
options | LockOptions |
unlock()
unlock() => Promise<void>Unlocks the device orientation.
getCurrentOrientation()
getCurrentOrientation() => Promise<GetCurrentOrientationResult>Gets the current device orientation type.
Returns: Promise<GetCurrentOrientationResult>
Interfaces
LockOptions
| Prop | Type | Description |
|---|---|---|
type | OrientationType | The orientation lock type. |
GetCurrentOrientationResult
| Prop | Type | Description |
|---|---|---|
type | OrientationType | The orientation lock type. |
Enums
OrientationType
| Members | Value | Description |
|---|---|---|
LANDSCAPE | 'landscape' | The orientation is either landscape-primary or landscape-secondary. |
LANDSCAPE_PRIMARY | 'landscape-primary' | The orientation is in the primary landscape mode. |
LANDSCAPE_SECONDARY | 'landscape-secondary' | The orientation is in the secondary landscape mode. |
PORTRAIT | 'portrait' | The orientation is either portrait-primary or portrait-secondary. |
PORTRAIT_PRIMARY | 'portrait-primary' | The orientation is in the primary portrait mode. |
PORTRAIT_SECONDARY | 'portrait-secondary' | The orientation is in the secondary portrait mode. |
Changelog
See CHANGELOG.md.
License
See LICENSE.
1.1.7-dev.abed386.1659603579
3 years ago
1.1.5-dev.c1093fb.1649973176
4 years ago
1.1.5-dev.698d97d.1650353439
4 years ago
1.1.7
4 years ago
1.1.6
4 years ago
1.1.5
4 years ago
1.1.5-dev.a2dfb78.1649947447
4 years ago
1.1.2-dev.a1e395e.1641942951
4 years ago
1.1.4
4 years ago
1.1.3
4 years ago
1.1.2
4 years ago
1.1.1-dev.b2d8835.1641590822
4 years ago
1.1.1
4 years ago
1.1.0-dev.09c2161.1639481757
4 years ago
1.1.0
4 years ago
1.0.2-dev.84d41a8.1630006674
4 years ago
1.0.2
4 years ago
1.0.1
5 years ago
1.0.0
5 years ago
0.0.1-dev.43d3802
5 years ago
0.0.1-dev.4fe3139
5 years ago