Skip to content

Latest commit

 

History

History
39 lines (30 loc) · 1.67 KB

index.md

File metadata and controls

39 lines (30 loc) · 1.67 KB
category
Sensors

useDeviceMotion

Reactive DeviceMotionEvent. Provide web developers with information about the speed of changes for the device's position and orientation.

Usage

import { useDeviceMotion } from '@vueuse/core'

const {
  acceleration,
  accelerationIncludingGravity,
  rotationRate,
  interval,
} = useDeviceMotion()
State Type Description
acceleration object An object giving the acceleration of the device on the three axis X, Y and Z.
accelerationIncludingGravity object An object giving the acceleration of the device on the three axis X, Y and Z with the effect of gravity.
rotationRate object An object giving the rate of change of the device's orientation on the three orientation axis alpha, beta and gamma.
interval Number A number representing the interval of time, in milliseconds, at which data is obtained from the device..

You can find more information about the state on the MDN.

Component Usage

<template>
  <UseDeviceMotion v-slot="{ acceleration }">
    Acceleration: {{ acceleration }}
  </UseDeviceMotion>
</template>