Device Orientation Events
The DeviceOrientationEvent() constructor creates a new DeviceOrientationEvent object.
Syntax
new DeviceOrientationEvent(type)
new DeviceOrientationEvent(type, options)
Parameters
type- : A string with the name of the event.
It is case-sensitive and browsers set it to
deviceorientationordeviceorientationabsolute. In the latter case,options.absoluteis alwaystrue.
- : A string with the name of the event.
It is case-sensitive and browsers set it to
options- : An object that, in addition of the properties defined in Event/Event, can have the following properties:
alpha- : A number representing the motion of the device around the z axis,
expressed in degrees with values ranging from 0 to 360.
It defaults to
null.
- : A number representing the motion of the device around the z axis,
expressed in degrees with values ranging from 0 to 360.
It defaults to
beta- : A number representing the motion of the device around the x axis,
expressed in degrees with values ranging from -180 to 180.
This represents a front to back motion of the device.
It defaults to
null.
- : A number representing the motion of the device around the x axis,
expressed in degrees with values ranging from -180 to 180.
This represents a front to back motion of the device.
It defaults to
gamma- : A number representing the motion of the device around the y axis,
expressed in degrees with values ranging from -90 to 90.
This represents a left to right motion of the device.
It defaults to
null.
- : A number representing the motion of the device around the y axis,
expressed in degrees with values ranging from -90 to 90.
This represents a left to right motion of the device.
It defaults to
absolute- : A boolean value that indicates whether or not the device is providing orientation data absolutely.
It defaults to
false.
- : A boolean value that indicates whether or not the device is providing orientation data absolutely.
It defaults to
- : An object that, in addition of the properties defined in Event/Event, can have the following properties:
Return value
A new DeviceOrientationEvent object.
Specifications
Browser compatibility
来源:MDN Web Docs / Mozilla 贡献者 · 作者与贡献记录 · CC BY-SA 2.5。离线整理了版式、链接和媒体显示。
