Socket
Book a DemoInstallSign in
Socket

react-native-direction-control

Package Overview
Dependencies
Maintainers
1
Versions
12
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-native-direction-control

A React Native component for handling directional inputs, perfect for interactive applications requiring gesture and directional control.

latest
Source
npmnpm
Version
1.2.2
Version published
Maintainers
1
Created
Source

react-native-direction-control

npm version npm downloads Coverage Status code style: prettier

A flexible and feature-rich button component for React Native applications, offering a variety of customization options including icons, subtitles, loading state, and more.

react-native-direction-control is a React Native module for managing and controlling the device's screen direction. This module allows you to programmatically lock the device's screen to a specific direction and detect orientation changes.

toast gif

Features

  • Retrieve the current screen direction.
  • Lock the screen to a specific direction (landscape/portrait).
  • Unlock screen direction to allow all orientations.
  • Add and remove listeners for screen direction changes.

Installation

npm install react-native-direction-control
# or
yarn add react-native-direction-control

Usage

import { DirectionControl } from 'react-native-direction-control';

// Get current screen direction
DirectionControl.getOrientation().then(direction => {
  console.log(direction);
});

// Lock to landscape direction
DirectionControl.lockToLandscape();

// Lock to portrait direction
DirectionControl.lockToPortrait();

// Unlock all orientations
DirectionControl.unlockAllDirections();

// Add a listener for direction changes
const onDirectionChange = direction => {
  console.log('Screen direction changed to:', direction);
};
DirectionControl.addDirectionChangeListener(onDirectionChange);

// Remove the listener
DirectionControl.removeDirectionChangeListener(onDirectionChange);

API

Methods

  • getOrientation(): Promise
  • lockToPortrait(): void
  • lockToLandscape(): void
  • unlockAllDirections(): void
  • addDirectionChangeListener(callback: Function): void
  • removeDirectionChangeListener(callback: Function): void

License

This project is licensed under the MIT License.

Keywords

react-native

FAQs

Package last updated on 17 Mar 2024

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

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.