JSPM

@jigrawesome/jigra-screen-orientation

6.0.1
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 1
  • Score
    100M100P100Q22471F
  • License MIT

Jigra plugin to lock/unlock the screen orientation.

Package Exports

  • @jigrawesome/jigra-screen-orientation
  • @jigrawesome/jigra-screen-orientation/dist/esm/index.js
  • @jigrawesome/jigra-screen-orientation/dist/plugin.cjs.js

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (@jigrawesome/jigra-screen-orientation) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

@jigrawesome/jigra-screen-orientation

Jigra plugin to lock/unlock the screen orientation.

Installation

npm install @jigrawesome/jigra-screen-orientation
npx jig sync

iOS

On iOS you must add the following to your app's AppDelegate.swift:

+ import JigrawesomeJigraScreenOrientation

@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate {

+ func application(_ application: UIApplication, supportedInterfaceOrientationsFor window: UIWindow?) -> UIInterfaceOrientationMask {
+   return ScreenOrientation.getSupportedInterfaceOrientations()
+ }

Configuration

No configuration required for this plugin.

Usage

import { ScreenOrientation, OrientationType } from '@jigrawesome/jigra-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>


addListener('screenOrientationChange', ...)

addListener(eventName: 'screenOrientationChange', listenerFunc: ScreenOrientationChangeListener) => Promise<PluginListenerHandle>

Listen for screen orientation changes.

Param Type
eventName 'screenOrientationChange'
listenerFunc ScreenOrientationChangeListener

Returns: Promise<PluginListenerHandle>


removeAllListeners()

removeAllListeners() => Promise<void>

Remove all listeners for this plugin.


Interfaces

LockOptions

Prop Type Description
type OrientationType The orientation lock type.

GetCurrentOrientationResult

Prop Type Description
type OrientationType The current orientation type.

PluginListenerHandle

Prop Type
remove () => Promise<void>

ScreenOrientationChange

Prop Type Description
type OrientationType The current orientation type.

Type Aliases

ScreenOrientationChangeListener

Callback to receive the screen orientation change notifications.

(change: ScreenOrientationChange): void

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.