sensors-orientation
TypeScript icon, indicating that this package has built-in type declarations

1.2.0 • Public • Published

sensors-orientation

pPwj35V.png

A draggable DOM component that simulates Orientation, similar to the browser devtools, and matches the behavior of the browser devtools.

Usage

Demo

yarn 

yarn demo

Install

yarn add sensors-orientation

Use in Vue

import { ref, onMounted } from 'vue'
import registerOrientation from 'sensors-orientation'
import 'sensors-orientation/dist/index.css'
// import type {OrientationView} from 'sensors-orientation'


const manager = ref(null)

function reset() {
    manager.value.resetDeviceOrientation();
}

// 生命周期钩子
onMounted(() => {
  manager.value = registerOrientation(document.querySelector('.orientation'));
  manager.value.onChangeDeviceOrientation(args => {
    console.error('onChangeDeviceOrientation', args);
  })
})

API

registerOrientation

register orientation, use it first.

params

  1. dom: HTMLElement

return

Return a manager of type OrientationView

manager.resetDeviceOrientation

reset the orientation data to [0, 90, 0]

manager.onChangeDeviceOrientation

listens the orientation data changes and triggers a callback

params

  1. callback: ChangedFCType

manager.setDeviceOrientation

set device orientation, like user input.

params

  1. orientation: OrientationType

Type

  • OrientationType
  • OrientationView

Readme

Keywords

none

Package Sidebar

Install

npm i sensors-orientation

Weekly Downloads

4

Version

1.2.0

License

MIT

Unpacked Size

33.8 kB

Total Files

14

Last publish

Collaborators

  • simida