1.2.0 • Published 8 months ago

sensors-orientation v1.2.0

Weekly downloads
-
License
MIT
Repository
-
Last release
8 months ago

sensors-orientation

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
1.2.0

8 months ago

1.1.3

9 months ago

1.1.2

9 months ago

1.1.1

9 months ago

1.1.0

9 months ago

1.0.0

9 months ago