useVibrate
Hook that provides vibrate api
browser
low
test coverage
Last changed: 7 months ago
TIP
This hook uses navigator.vibrate browser api to provide enhanced functionality. Make sure to check for compatibility with different browsers when using this api
Installation
Library
CLI
Manual
typescript
import { useVibrate } from '@siberiacancode/reactuse';Usage
typescript
const { supported, active, vibrate, stop, pause, resume } = useVibrate(1000);Demo
Api
Parameters
| Name | Type | Default | Note |
|---|---|---|---|
| options.pattern | UseVibratePattern | - | The pattern for vibration |
| options.interval? | number | 0 | Time in milliseconds between vibrations |
Returns
UseVibrateReturn
Type declaration
typescript
export type UseVibratePattern = number | number[];
export interface UseVibrateReturn {
/** The support indicator */
supported: boolean;
/** The vibrating indicator */
vibrating: boolean;
/** The pause function */
pause: () => void;
/** The resume function */
resume: () => void;
/** The start function */
start: (interval: number) => void;
/** The vibrate function */
trigger: (pattern?: UseVibratePattern) => void;
}Source
Source • DemoContributors
D
N