Skip to content
0

katanakit-js / useOnDeviceMotion

Function: useOnDeviceMotion() ​

ts
function useOnDeviceMotion(callback): (() => void) | null;

Defined in: src/infrastructure/sensors/sensors.service.ts:254

Listens for device motion events (acceleration, rotation rate).

Parameters ​

ParameterTypeDescription
callback(event) => voidCalled with each DeviceMotionEvent.

Returns ​

(() => void) | null

A cleanup function that removes the listener, or null if unavailable.

Example ​

ts
const off = useOnDeviceMotion((e) => {
  console.log("Acceleration:", e.acceleration);
});

Released under the MIT License.