Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@capawesome/capacitor-screen-orientation

Package Overview
Dependencies
Maintainers
1
Versions
9
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@capawesome/capacitor-screen-orientation

Capacitor plugin to lock/unlock the screen orientation.

  • 2.0.1
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
4.6K
decreased by-42.19%
Maintainers
1
Weekly downloads
 
Created
Source


Screen Orientation

@capawesome/capacitor-screen-orientation

Capacitor plugin to lock/unlock the screen orientation.


Maintainers

MaintainerGitHubSocial
Robin Genzrobingenz@robin_genz

Sponsors

This is an MIT-licensed open source project. It can grow thanks to the support by these awesome people. If you'd like to join them, please read more here.

Installation

npm install @capawesome/capacitor-screen-orientation
npx cap sync

iOS

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

+ import CapawesomeCapacitorScreenOrientation

@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, OrientationType } from '@capawesome/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.

ParamType
optionsLockOptions

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> & PluginListenerHandle

Listen for screen orientation changes.

ParamType
eventName'screenOrientationChange'
listenerFuncScreenOrientationChangeListener

Returns: Promise<PluginListenerHandle> & PluginListenerHandle


removeAllListeners()

removeAllListeners() => Promise<void>

Remove all listeners for this plugin.


Interfaces

LockOptions
PropTypeDescription
typeOrientationTypeThe orientation lock type.
GetCurrentOrientationResult
PropTypeDescription
typeOrientationTypeThe current orientation type.
PluginListenerHandle
PropType
remove() => Promise<void>
ScreenOrientationChange
PropTypeDescription
typeOrientationTypeThe current orientation type.

Type Aliases

ScreenOrientationChangeListener

Callback to receive the screen orientation change notifications.

(change: ScreenOrientationChange): void

Enums

OrientationType
MembersValueDescription
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.

Keywords

FAQs

Package last updated on 19 Aug 2022

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc