useDeviceMotion ​
utilities
test coverage
Last changed: 28 days ago
TIP
This hook uses DeviceMotionEvent browser api to provide enhanced functionality. Make sure to check for compatibility with different browsers when using this api
Hook that work with device motion
typescript
import { useDeviceMotion } from '@siberiacancode/reactuse';
Usage ​
typescript
const { interval, rotationRate, acceleration, accelerationIncludingGravity } = useDeviceMotion();
Demo ​
Api ​
Parameters
Name | Type | Default | Note |
---|---|---|---|
delay? | number | 1000 | The delay in milliseconds |
callback? | (event: DeviceMotionEvent) => void | - | The callback function to be invoked |
enabled? | boolean | true | Whether to enable the hook |