npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@capawesome/capacitor-screen-orientation

v6.0.0

Published

Capacitor plugin to lock/unlock the screen orientation.

Downloads

23,264

Readme

@capawesome/capacitor-screen-orientation

Capacitor plugin to lock/unlock the screen orientation.

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.

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

Credits

This plugin is based on the Capacitor Screen Orientation plugin. Thanks to everyone who contributed to the project!