Class DeviceMotionEvent
- Namespace
- CSharpToJavaScript.APIs.JS
- Assembly
- CSharpToJavaScript.dll
The DeviceMotionEvent interface of the {{domxref("Device Orientation Events", "", "", "nocode")}} provides web developers with information about the speed of changes for the device's position and orientation.
[Value("DeviceMotionEvent")]
public class DeviceMotionEvent : Event
- Inheritance
-
DeviceMotionEvent
- Inherited Members
Remarks
WARNING
Currently, Firefox and Chrome do not handle the coordinates the same way. Take care about this while using them.
-{{domxref("Device orientation events/Detecting device orientation", "Detecting device orientation", "", "nocode")}}
-{{domxref("Device orientation events/Orientation and motion data explained", "Orientation and motion data explained", "", "nocode")}}
-DeviceOrientationEvent
-Window.Deviceorientation event
-Window.Deviceorientationabsolute event
-Windowdevicemotion event
-Accelerometer
-LinearAccelerationSensor
Constructors
DeviceMotionEvent()
public DeviceMotionEvent()
DeviceMotionEvent(string, DeviceMotionEventInit)
The DeviceMotionEvent() constructor creates a new DeviceMotionEvent object.
public DeviceMotionEvent(string type, DeviceMotionEventInit eventInitDict = null)
Parameters
typestringeventInitDictDeviceMotionEventInit
Remarks
Properties
Acceleration
The acceleration read-only property of the DeviceMotionEvent interface returns the acceleration recorded by
the device, in meters per second squared (m/s²).
This value does not include the effect of
the gravitational force, in contrast to AccelerationIncludingGravity.
[Value("acceleration")]
public DeviceMotionEventAcceleration? Acceleration { get; }
Property Value
- DeviceMotionEventAcceleration
The
accelerationproperty is an object providing information about
acceleration on the three axes in the Device coordinate frame. Each axis is represented with its own property:
Remarks
NOTE
If the hardware does not know how to remove gravity from the
acceleration data, this value may not be present in the
DeviceMotionEvent. In this situation, you'll need to use
AccelerationIncludingGravity instead.
-{{domxref("Device orientation events/Detecting device orientation", "Detecting device orientation", "", "nocode")}}
-{{domxref("Device orientation events/Orientation and motion data explained", "Orientation and motion data explained", "", "nocode")}}
-Windowdevicemotion event
AccelerationIncludingGravity
The accelerationIncludingGravity read-only property of the DeviceMotionEvent interface returns the
amount of acceleration recorded by the device, in meters per second squared (m/s²). Unlike Acceleration
which compensates for the influence of gravity, its value is the sum of the acceleration
of the device as induced by the user and an acceleration equal and opposite to that
caused by gravity. In other words, it measures the
g-force. In practice, this value represents
the raw data measured by an accelerometer.
[Value("accelerationIncludingGravity")]
public DeviceMotionEventAcceleration? AccelerationIncludingGravity { get; }
Property Value
- DeviceMotionEventAcceleration
The
accelerationIncludingGravityproperty is an object providing
information about acceleration on three axis. Each axis is represented with its own
property:
Remarks
This value is not typically as useful as Acceleration,
but may be the only value available on devices that aren't able to remove gravity from
the acceleration data, such as on devices that don't have a gyroscope.
NOTE
accelerationIncludingGravity's name can be misleading. This property represents acceleration including the effects of gravity. For example, if a device is lying flat on a horizontal surface with the screen pointing up, gravity would be -9.8 along the Z axis, whileacceleration.zwould be 0 andaccelerationIncludingGravity.zwould be 9.8. Similarly, if a device is in free fall with its screen horizontal and pointing up, gravity would be -9.8 along the Z axis, whileacceleration.zwould be -9.8 andaccelerationIncludingGravity.zwould be 0.
-{{domxref("Device orientation events/Detecting device orientation", "Detecting device orientation", "", "nocode")}}
-{{domxref("Device orientation events/Orientation and motion data explained", "Orientation and motion data explained", "", "nocode")}}
-Windowdevicemotion event
Interval
The interval read-only property of the DeviceMotionEvent interface returns the interval, in milliseconds, at which data is obtained from the underlying
hardware. You can use this to determine the granularity of motion events.
[Value("interval")]
public Number Interval { get; }
Property Value
- Number
A number representing the interval of time, in milliseconds.
Remarks
-{{domxref("Device orientation events/Detecting device orientation", "Detecting device orientation", "", "nocode")}}
-{{domxref("Device orientation events/Orientation and motion data explained", "Orientation and motion data explained", "", "nocode")}}
-Windowdevicemotion event
RotationRate
The rotationRate read-only property of the DeviceMotionEvent interface returns the rate at which the device is rotating around each of its axes in degrees per
second.
[Value("rotationRate")]
public DeviceMotionEventRotationRate? RotationRate { get; }
Property Value
- DeviceMotionEventRotationRate
The
rotationRateproperty is a read only object describing the rotation
rates of the device around each of its axes:
Remarks
NOTE
If the hardware isn't capable of providing this
information, this property returnsnull.
-{{domxref("Device orientation events/Detecting device orientation", "Detecting device orientation", "", "nocode")}}
-{{domxref("Device orientation events/Orientation and motion data explained", "Orientation and motion data explained", "", "nocode")}}
-Windowdevicemotion event
Methods
RequestPermission()
[Value("requestPermission")]
public static Task<PermissionState> RequestPermission()