RotationListenerConfig
interface RotationListenerConfig {
customPermissionFunction?: () => Promise<boolean>;
onPermissionDenied: () => void;
onPermissionGranted: () => void;
onStart: () => void;
pollingRate: number;
startOnInit: boolean;
}Source: types.ts:51
Example
deviceRotation.setConfig({
pollingRate: 30,
startOnInit: false,
onStart: () => console.log("Orientation tracking active"),
onPermissionDenied: () => console.warn("Orientation permission denied"),
});Properties
customPermissionFunction: () => Promise<boolean>
Custom asynchronous function to override the built-in permission request workflow.
Can be used to hook into custom UI prompts or authorization flows before invoking DeviceOrientationEvent.requestPermission().
Example
customPermissionFunction: async () => {
const res = await (DeviceOrientationEvent as any).requestPermission();
return res === "granted";
}onPermissionDenied: () => void
Callback invoked whenever a device orientation permission request is rejected or denied.
Default: `() => {}`
onPermissionGranted: () => void
Callback invoked whenever device orientation permission is successfully granted.
Default: `() => {}`
onStart: () => void
Callback invoked when orientation listener starts actively listening to events.
Default: `() => {}`
pollingRate: number
Maximum number of orientation updates to emit per second (Hz).
Updates will be throttled so they do not exceed this frequency.
Default: `60`
startOnInit: boolean
Whether orientation listening should automatically start as soon as deviceRotation.onUpdate is registered.
If set to false, listening must be manually started by calling deviceRotation.start.
Default: `true`