Skip to content

useDeviceOrientation

Category
Export Size
308 B
Last Changed
5 days ago

Reactive DeviceOrientationEvent

Demo

Usage

tsx
import { 
useDeviceOrientation
} from '@reause/core'
const {
isAbsolute
,
alpha
,
beta
,
gamma
} =
useDeviceOrientation
()
StateTypeDescription
isAbsoluteboolean | nullWhether the device orientation is absolute (relative to the Earth's coordinate system) or relative to the device.
alphanumber | nullThe rotation of the device around the z axis (0–360 degrees).
betanumber | nullThe rotation of the device around the x axis (−180–180 degrees).
gammanumber | nullThe rotation of the device around the y axis (−90–90 degrees).

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

Type Declarations

ts
export interface UseDeviceOrientationOptions extends ConfigurableWindow {
}

export interface UseDeviceOrientationReturn {
    isSupported: boolean;
    isAbsolute: boolean | null;
    alpha: number | null;
    beta: number | null;
    gamma: number | null;
}

export function useDeviceOrientation(options?: UseDeviceOrientationOptions): UseDeviceOrientationReturn

Source

Source · Demo · VueUse

Contributors

hairyf

Changelog

v0.1.0 on
48bd8 - fix(core): resolve useDeviceOrientation audit findings (#540)
e16c8 - feat(core): add useDeviceOrientation (#108)

Released under the MIT License. v0.1.8