@nativescript-use/nativescript-orientation
TypeScript icon, indicating that this package has built-in type declarations

0.0.3 • Public • Published

@nativescript-use/nativescript-orientation

npm install @nativescript-use/nativescript-orientation

Usage

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();

Type declaration

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
}

License

Apache License Version 2.0

Package Sidebar

Install

npm i @nativescript-use/nativescript-orientation

Weekly Downloads

3

Version

0.0.3

License

Apache-2.0

Unpacked Size

32.4 kB

Total Files

13

Last publish

Collaborators

  • vallemar89