0.0.3 • Published 3 years ago
@warpsoft/screen-orientation v0.0.3
@warpsoft/screen-orientation
控制手机屏幕方向的插件
Install
npm install @warpsoft/screen-orientation
npx cap sync
iOS
For iOS, you must make the following adjustments to your AppDelegate.swift
file:
import UIKit
...snip...
+ import WarpsoftScreenOrientation
@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate {
...snip...
+ func application(_ application: UIApplication, supportedInterfaceOrientationsFor window: UIWindow?) -> UIInterfaceOrientationMask {
+ return ScreenOrientationPlugin.supportedOrientations
+ }
...snip...
}
API
orientation()
orientation() => Promise<{ type: OrientationMode; }>
获取屏幕当前的方向
Returns: Promise<{ type: OrientationMode; }>
lock(...)
lock(options: LockOptions) => Promise<void>
使得屏幕旋转到某个方向上并锁定
Param | Type | Description |
---|---|---|
options | LockOptions | 选项参数 |
unlock()
unlock() => Promise<void>
解锁屏幕方向的锁定
Interfaces
LockOptions
旋转并锁定屏幕方向的参数
Prop | Type | Description |
---|---|---|
type | OrientationMode | 方向 |
Enums
OrientationMode
Members | Value | Description |
---|---|---|
PORTRAIT_PRIMARY | 'portrait-primary' | 纵向-正面 |
PORTRAIT_SECONDARY | 'portrait-secondary' | 纵向-反面 |
LANDSCAPE_PRIMARY | 'landscape-primary' | 横向-正面 |
LANDSCAPE_SECONDARY | 'landscape-secondary' | 横向-反面 |