Magnetic Field Events: Difference between revisions

no edit summary
mNo edit summary
No edit summary
Line 6: Line 6:


This is achieved by interrogating a magnetic field sensor or similar detectors of a device.  
This is achieved by interrogating a magnetic field sensor or similar detectors of a device.  
=== Use cases  ===


== Conformance  ==
== Conformance  ==
Line 26: Line 24:


The concepts '''''[http://dvcs.w3.org/hg/domcore/raw-file/tip/Overview.html#constructing-events create an event]''''' and '''''[http://dvcs.w3.org/hg/domcore/raw-file/tip/Overview.html#firing-events fire an event]''''' are defined in [DOM4].
The concepts '''''[http://dvcs.w3.org/hg/domcore/raw-file/tip/Overview.html#constructing-events create an event]''''' and '''''[http://dvcs.w3.org/hg/domcore/raw-file/tip/Overview.html#firing-events fire an event]''''' are defined in [DOM4].
The '''''current device magnetic field''''' is the magnetic field intensity vector near the hosting device. It is represented by three components ''x'', ''y'' and ''z'' in X, Y and -Z axis of the device coordinate system in micro-Tesla (uT) unit.
NOTE
:The magnetic field's Z axis is inverted.
The '''''[http://developer.android.com/reference/android/hardware/SensorListener.html device coordinate system'''''] is a orthogonal coordinate system in which the X axis refers to the screen's horizontal axis (the small edge in portrait mode, the long edge in landscape mode) and points to the right, the Y axis refers to the screen's vertical axis and points towards the top of the screen (the origin is in the lower-left corner), and the Z axis points toward the sky when the device is lying on its back on a table.
NOTE
:The axis are swapped when the device's screen orientation changes.


== Security and privacy considerations  ==
== Security and privacy considerations  ==
Line 62: Line 70:
'''x''' of type double, readonly  
'''x''' of type double, readonly  


:Ambient magnetic field in the X axis.
:Ambient magnetic field in the X axis of the device coordinate system in uT.


'''y''' of type double, readonly  
'''y''' of type double, readonly  


:Ambient magnetic field in the Y axis.
:Ambient magnetic field in the Y axis of the device coordinate system in uT.


'''z''' of type double, readonly  
'''z''' of type double, readonly  


:Ambient magnetic field in the Z axis.
:Ambient magnetic field in the -Z axis of the device coordinate system in uT.


==== Dictionary DeviceMagneticFieldEventInit Members  ====
==== Dictionary DeviceMagneticFieldEventInit Members  ====
Line 79: Line 87:


'''z''' of type double  
'''z''' of type double  
When a user agent is required to '''''fire a device magnetic field event''''', the user agent must run the following steps:
# Create an event that uses the '''DeviceMagneticFieldEvent''' interface, with the name ''devicemagneticfield'', which bubbles, is not cancelable, and has no default action, that also meets the following conditions:
## If the implementation is unable to report the current device light, initialize the ''x'', ''y'' and ''z'' attribute to positive Infinity, otherwise initialize the attribute to the '''''current device magnetic field'''''.
# Queue a task to dispatch the newly created event at the Window object.
When the '''''current device magnetic field''''' changes, the user agent must '''''fire a device magnetic field event'''''.
NOTE
:The definition of granularity i.e. how often the event is fired is left to the implementation. Implementations may fire the event if they have reason to believe that the page does not have sufficiently fresh data.


==== Event handlers  ====
==== Event handlers  ====
Line 91: Line 111:


== References  ==
== References  ==
===Normative references===


[DOM4]
[DOM4]
Line 103: Line 125:


:Ian Hickson; David Hyatt. [http://www.w3.org/TR/html5 HTML5]. 29 March 2012. W3C Working Draft. (Work in progress.) URL: http://www.w3.org/TR/html5
:Ian Hickson; David Hyatt. [http://www.w3.org/TR/html5 HTML5]. 29 March 2012. W3C Working Draft. (Work in progress.) URL: http://www.w3.org/TR/html5
===Informative references===
No informative references.
Confirmed users
19

edits