npm i --save @nativescript-use/nativescript-orientation
- 版本: 0.0.3
- GitHub: https://github.com/NativeScript-Use/NativeScript-Use
- NPM: https://npmjs.net.cn/package/%40nativescript-use%2Fnativescript-orientation
- 下载
- 前一天: 7
- 上周: 54
- 上个月: 100
@nativescript-use/nativescript-orientation
npm install @nativescript-use/nativescript-orientation
使用情况
import { Orientation } from "@nativescript-use/nativescript-orientation"
const orientation = new Orientation();
// Get current orientation
const currentOrientation = orientation.getOrientation();
// Change orientation. values: 'landscape' | 'landscaperight' | 'landscapeleft' | 'portrait'
orientation.setOrientation('landscape');
// Enable rotation
orientation.enableRotation();
// Disable rotation
orientation.disableRotation();
// Add listener
orientation.onChangedOrientation((newValue: CoreTypes.DeviceOrientationType) =>{
console.log(newValue)
});
// Remove listener
orientation.offChangedOrientation();
类型声明
export declare class Orientation {
getOrientation(): CoreTypes.DeviceOrientationType
onChangedOrientation(callback: (newValue: CoreTypes.DeviceOrientationType) => void): void
offChangedOrientation(): void
enableRotation(): void
disableRotation(): void
setOrientation(value: 'landscape' | 'landscaperight' | 'landscapeleft' | 'portrait', animation: false): void
}
许可证
Apache 许可证版本 2.0