screen-orientation-2

1.0.1 • Public • Published

Get the current screen orientation

Install

$ npm install --save screen-orientation-2

or

$ npm add screen-orientation-2

Usage

Import module

const screenOrientation = require('screen-orientation-2')
screenOrientation()
//=> {direction: 'landscape', version: 'primary', angle: 0}

Or

screenOrientation.getScreenOrientation()
//=> {direction: 'landscape', version: 'primary', angle: 0}
screenOrientation.addEventOnOrientationChange((newOrientation) => {
  console.log(newOrientation)
  //=> {direction: 'landscape', version: 'primary', angle: 0}
})
screenOrientation.removeEventOnOrientationChange()
//=> void
screenOrientation.setUseOrientation()
//=> void
screenOrientation.setUseWindowSize()
//=> void

API

screenOrientation() -> object

Returns the current screen orientation (direction, version and angle).

screenOrientation.getScreenOrientation() -> object

Returns the current screen orientation (direction, version and angle).

screenOrientation.addEventOnOrientationChange(callback) -> void

Add a callback function when screen orientation is changed

Example:

const refreshFrames(newOrientation) {
  // myFunction (newOrientation.direction, newOrientation.version)
};

screenOrientation.addEventOnOrientationChange(refreshFrames)

screenOrientation.removeEventOnOrientationChange() -> void

Remove a callback function when screen orientation is changed

screenOrientation.setUseOrientation() -> void

Force use window.screen.orientation object

screenOrientation.setUseWindowSize() -> void

Force use window size

License

MIT © Medeiros Dev

Readme

Keywords

Package Sidebar

Install

npm i screen-orientation-2

Weekly Downloads

3

Version

1.0.1

License

MIT

Unpacked Size

5.83 kB

Total Files

4

Last publish

Collaborators

  • medeirosdev