A draggable DOM component that simulates Orientation, similar to the browser devtools, and matches the behavior of the browser devtools.
yarn
yarn demo
yarn add sensors-orientation
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);
})
})
register orientation, use it first.
- dom:
HTMLElement
Return a manager
of type OrientationView
reset the orientation data to [0, 90, 0]
listens the orientation data changes and triggers a callback
- callback:
ChangedFCType
set device orientation, like user input.
- orientation:
OrientationType
OrientationType
OrientationView