1.0.1 • Published 4 years ago
screen-orientation-2 v1.0.1
Get the current screen orientation
Install
$ npm install --save screen-orientation-2or
$ npm add screen-orientation-2Usage
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()
//=> voidscreenOrientation.setUseOrientation()
//=> voidscreenOrientation.setUseWindowSize()
//=> voidAPI
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