Skip to content

A React Native component for multi-directional navigation controls, featuring gesture recognition, customizable UI, and enhanced performance for map and navigation apps, leveraging native capabilities

License

npmhub90/react-native-direction-control

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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.

About

A React Native component for multi-directional navigation controls, featuring gesture recognition, customizable UI, and enhanced performance for map and navigation apps, leveraging native capabilities

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published