# @jigra/screen-orientation

> The Screen Orientation API provides methods to lock and unlock the screen orientation.

Latest version **6.0.2** (published 2024-09-20) · MIT license · 0 weekly downloads

## Install

```sh
npm install @jigra/screen-orientation
pnpm add @jigra/screen-orientation
yarn add @jigra/screen-orientation
bun add @jigra/screen-orientation
```

## Health

**Score 30/100 (F)** — status: abandoned.

Positive: has types; esm support; no vulnerabilities; has provenance.

Warnings: low downloads.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 6.0.2 |
| Published | 2024-09-20 |
| First published | 2023-05-24 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 0 |
| Unpacked size | 49.6 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Provenance | attested (Unknown) |
| Author | Family |
| Maintainers | nkduy |
| Keywords | jigra, plugin, native |

## Links

- npm: https://www.npmjs.com/package/@jigra/screen-orientation
- Repository: https://github.com/familyjs/jigra-plugins
- Homepage: https://github.com/familyjs/jigra-plugins#readme
- Issues: https://github.com/familyjs/jigra-pluginsissues
- npm.io page: https://npm.io/package/@jigra/screen-orientation

## Recent versions

- 6.0.2 (latest) — 2024-09-20
- 6.0.3-weekly-20241124T232317.0 (weekly) — 2024-11-24
- 6.0.0-rc.1 (next) — 2024-09-12
- 6.0.0-alpha.4 (latest-6) — 2024-09-12
- 5.0.10 (latest-5) — 2024-09-10
- 5.0.3-nightly-20230802T151652.0 (nightly) — 2023-08-02
- 6.0.3-weekly-20241117T232223.0 — 2024-11-17
- 6.0.3-weekly-20241110T232109.0 — 2024-11-10
- 6.0.3-weekly-20241103T232313.0 — 2024-11-03
- 6.0.3-weekly-20241027T232238.0 — 2024-10-27
- 6.0.3-weekly-20241020T232229.0 — 2024-10-20
- 6.0.3-weekly-20241013T232451.0 — 2024-10-13
- 6.0.3-weekly-20241006T232038.0 — 2024-10-06
- 6.0.3-weekly-20240929T232053.0 — 2024-09-29
- 6.0.3-weekly-20240922T232251.0 — 2024-09-22
- … 67 more at https://npm.io/package/@jigra/screen-orientation/versions

## README

# @jigra/screen-orientation

The Screen Orientation API provides information and functionality related to the orientation of the screen.

## Install

```bash
npm install @jigra/screen-orientation
npx jig sync
```

## iOS

Locking the Screen Orientation only works for the Jigra View Controller only, but not other View Controllers being presented (such as the one presented by Browser plugin).
For also lock presented View Controllers, this code can be added to the app's `AppDelegate.swift` file:

```swift
func application(_ application: UIApplication, supportedInterfaceOrientationsFor window: UIWindow?) -> UIInterfaceOrientationMask {
  return UIInterfaceOrientationMask(rawValue: (self.window!.rootViewController as! JIGBridgeViewController).supportedInterfaceOrientations.rawValue)
}
```

### iPad Orientation Lock

By default, an iPad allows Multitasking and its orientation cannot be locked. If you need to lock orientation on an iPad set the option `Requires Full Screen` to `YES` by adding the following to `Info.plist`:

```
  <key>UIRequiresFullScreen</key>
  <true/>
```

## API

<docgen-index>

* [`orientation()`](#orientation)
* [`lock(...)`](#lock)
* [`unlock()`](#unlock)
* [`addListener('screenOrientationChange', ...)`](#addlistenerscreenorientationchange-)
* [`removeAllListeners()`](#removealllisteners)
* [Interfaces](#interfaces)
* [Type Aliases](#type-aliases)

</docgen-index>

<docgen-api>
<!--Update the source file JSDoc comments and rerun docgen to update the docs below-->

### orientation()

```typescript
orientation() => Promise<ScreenOrientationResult>
```

Returns the current screen orientation.

**Returns:** <code>Promise&lt;<a href="#screenorientationresult">ScreenOrientationResult</a>&gt;</code>

**Since:** 4.0.0

--------------------


### lock(...)

```typescript
lock(options: OrientationLockOptions) => Promise<void>
```

Locks the screen orientation.

| Param         | Type                                                                      |
| ------------- | ------------------------------------------------------------------------- |
| **`options`** | <code><a href="#orientationlockoptions">OrientationLockOptions</a></code> |

**Since:** 4.0.0

--------------------


### unlock()

```typescript
unlock() => Promise<void>
```

Unlocks the screen's orientation.

**Since:** 4.0.0

--------------------


### addListener('screenOrientationChange', ...)

```typescript
addListener(eventName: "screenOrientationChange", listenerFunc: (orientation: ScreenOrientationResult) => void) => Promise<PluginListenerHandle>
```

Listens for screen orientation changes.

| Param              | Type                                                                                                  |
| ------------------ | ----------------------------------------------------------------------------------------------------- |
| **`eventName`**    | <code>'screenOrientationChange'</code>                                                                |
| **`listenerFunc`** | <code>(orientation: <a href="#screenorientationresult">ScreenOrientationResult</a>) =&gt; void</code> |

**Returns:** <code>Promise&lt;<a href="#pluginlistenerhandle">PluginListenerHandle</a>&gt;</code>

**Since:** 4.0.0

--------------------


### removeAllListeners()

```typescript
removeAllListeners() => Promise<void>
```

Removes all listeners.

**Since:** 4.0.0

--------------------


### Interfaces


#### ScreenOrientationResult

| Prop       | Type                         |
| ---------- | ---------------------------- |
| **`type`** | <code>OrientationType</code> |


#### OrientationLockOptions

| Prop              | Type                                                                | Description                                                                                                                       |
| ----------------- | ------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------- |
| **`orientation`** | <code><a href="#orientationlocktype">OrientationLockType</a></code> | Note: Typescript v5.2+ users should import <a href="#orientationlocktype">OrientationLockType</a> from @jigra/screen-orientation. |


#### PluginListenerHandle

| Prop         | Type                                      |
| ------------ | ----------------------------------------- |
| **`remove`** | <code>() =&gt; Promise&lt;void&gt;</code> |


### Type Aliases


#### OrientationLockType

<code>"any" | "natural" | "landscape" | "portrait" | "portrait-primary" | "portrait-secondary" | "landscape-primary" | "landscape-secondary"</code>

</docgen-api>

---
_Source: https://npm.io/package/@jigra/screen-orientation · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
