1. Introduction
1.1. Overview
TODO.
1.2. Conformance
Boilerplate?
2. Stylistic Conventions
This specification follows the Proposed W3C Specification Conventions, with the following supplemental additions:
This is a note.
This is an open issue.
This is a warning.
interface Example { // This is an IDL definition. };
3. Wheel Events
Wheels are devices that can be rotated in one or more spatial dimensions, and which can be associated with a pointer device. The coordinate system depends on the environment configuration.
The user’s environment might be configured to associate vertical scrolling with rotation along the y-axis, horizontal scrolling with rotation along the x-axis, and zooming with rotation along the z-axis.
The deltaX, deltaY, and deltaZ attributes of WheelEvent
objects indicate
a measurement along their respective axes in units of pixels, lines, or
pages. The reported measurements are provided after an environment-specific
algorithm translates the actual rotation/movement of the wheel device into
the appropriate values and units.
A user’s environment settings can be customized to interpret actual rotation/movement
of a wheel device in different ways.
One movement of a common dented
mouse wheel can produce a measurement of 162 pixels
(162 is just an example value, actual values can depend on the current screen
dimensions of the user-agent).
But a user can change their default environment settings to speed-up their mouse wheel,
increasing this number.
Furthermore, some mouse wheel software can support acceleration (the faster the wheel
is rotated/moved, the greater the delta of each measurement) or even sub-pixel rotation measurements.
Because of this, authors can not assume a given rotation amount in one user agent will
produce the same delta value in all user agents.
The sign (positive or negative) of the values of the deltaX, deltaY, and deltaZ attributes
MUST be consistent between multiple dispatches of the wheel
event while the
motion of the actual wheel device is rotating/moving in the same direction.
If a user agent scrolls as the default action of the wheel
event then the sign
of the delta SHOULD be given by a right-hand coordinate system where positive X,
Y, and Z axes are directed towards the right-most edge, bottom-most edge, and farthest
depth (away from the user) of the document, respectively.
Individual user agents can (depending on their environment and hardware configuration) interpret the same physical user interaction on the wheel differently. For example, a vertical swipe on the edge of a trackpad from top to bottom can be interpreted as a wheel action intended to either scroll the page down or to pan the page up (i.e., resulting in either a positive or negative deltaY value respectively).
A user agent MUST create a wheel event transaction when the first wheel event is fired, so that all subsequent wheel events within a implementation-specific amount of time can be targetted at the same element. A wheel event transaction is series of wheel events that are associated with a single user gesture. The wheel event transaction MUST have an associated event target that is the topmost event target at the time the first wheel event occurs in the group.
If a series of wheel events targetted in a scrollable element start above a child element, later events for the same user gesture may occur over the child element.
3.1. Interface WheelEvent
Introduced in this specification
The WheelEvent
interface provides specific contextual information
associated with wheel
events.
To create an instance of the WheelEvent
interface, use the WheelEvent
constructor,
passing an optional WheelEventInit
dictionary.
3.1.1. WheelEvent
[Exposed =Window ]interface :
WheelEvent MouseEvent {(
constructor DOMString ,
type optional WheelEventInit = {}); // DeltaModeCode
eventInitDict const unsigned long DOM_DELTA_PIXEL = 0x00;const unsigned long DOM_DELTA_LINE = 0x01;const unsigned long DOM_DELTA_PAGE = 0x02;readonly attribute double deltaX ;readonly attribute double deltaY ;readonly attribute double deltaZ ;readonly attribute unsigned long deltaMode ; };
DOM_DELTA_PIXEL
- The units of measurement for the delta MUST be pixels. This is the most typical case in most operating system and implementation configurations.
DOM_DELTA_LINE
- The units of measurement for the delta MUST be individual lines of text. This is the case for many form controls.
DOM_DELTA_PAGE
- The units of measurement for the delta MUST be pages, either defined as a single screen or as a demarcated page.
deltaX
, of type double, readonly-
In user agents where the default action of the
wheel
event is to scroll, the value MUST be the measurement along the x-axis (in pixels, lines, or pages) to be scrolled in the case where the event is not cancelled. Otherwise, this is an implementation-specific measurement (in pixels, lines, or pages) of the movement of a wheel device around the x-axis.The un-initialized value of this attribute MUST be
0.0
. deltaY
, of type double, readonly-
In user agents where the default action of the
wheel
event is to scroll, the value MUST be the measurement along the y-axis (in pixels, lines, or pages) to be scrolled in the case where the event is not cancelled. Otherwise, this is an implementation-specific measurement (in pixels, lines, or pages) of the movement of a wheel device around the y-axis.The un-initialized value of this attribute MUST be
0.0
. deltaZ
, of type double, readonly-
In user agents where the default action of the
wheel
event is to scroll, the value MUST be the measurement along the z-axis (in pixels, lines, or pages) to be scrolled in the case where the event is not cancelled. Otherwise, this is an implementation-specific measurement (in pixels, lines, or pages) of the movement of a wheel device around the z-axis.The un-initialized value of this attribute MUST be
0.0
. deltaMode
, of type unsigned long, readonly-
The
deltaMode
attribute contains an indication of the units of measurement for the delta values. The default value isDOM_DELTA_PIXEL
(pixels).This attribute MUST be set to one of the DOM_DELTA constants to indicate the units of measurement for the delta values. The precise measurement is specific to device, operating system, and application configurations.
The un-initialized value of this attribute MUST be
0
.
3.1.2. WheelEventInit
dictionary :
WheelEventInit MouseEventInit {double deltaX = 0.0;double deltaY = 0.0;double deltaZ = 0.0;unsigned long deltaMode = 0; };
deltaX
, of type double, defaulting to0.0
- See
deltaZ
attribute. deltaY
, of type double, defaulting to0.0
- See
deltaZ
attribute. deltaZ
, of type double, defaulting to0.0
- Initializes the
deltaZ
attribute of theWheelEvent
object. Relative positive values for this attribute (as well as thedeltaX
anddeltaY
attributes) are given by a right-hand coordinate system where the X, Y, and Z axes are directed towards the right-most edge, bottom-most edge, and farthest depth (away from the user) of the document, respectively. Negative relative values are in the respective opposite directions. deltaMode
, of type unsigned long, defaulting to0
- Initializes the
deltaMode
attribute on theWheelEvent
object to the enumerated values 0, 1, or 2, which represent the amount of pixels scrolled (DOM_DELTA_PIXEL
), lines scrolled (DOM_DELTA_LINE
), or pages scrolled (DOM_DELTA_PAGE
) if the rotation of the wheel would have resulted in scrolling.
3.2. Wheel Event Types
3.2.1. wheel
Type | wheel
|
---|---|
Interface | WheelEvent
|
Sync / Async | Async |
Bubbles | Yes |
Trusted Targets | Element
|
Cancelable | Varies |
Composed | Yes |
Default action | Scroll (or zoom) the document |
Context (trusted events) |
|
A user agent MUST dispatch this event when a mouse wheel has
been rotated around any axis, or when an equivalent input device
(such as a mouse-ball, certain tablets or touchpads, etc.) has
emulated such an action. Depending on the platform and input device,
diagonal wheel deltas MAY be delivered either as a single wheel
event with multiple non-zero axes or as separate wheel
events for each non-zero axis.
The typical default action of the wheel
event type is
to scroll (or in some cases, zoom) the document by the indicated
amount. If this event is canceled, the implementation MUST NOT
scroll or zoom the document (or perform whatever other
implementation-specific default action is associated with this event
type).
In some user agents, or with some input devices, the speed that the wheel has been turned can affect the delta values, with a faster speed producing a higher delta value.
3.2.2. cancelability of wheel events
Calling preventDefault
on a wheel event can prevent
or otherwise interrupt scrolling. For maximum scroll performance, a
user agent may not wait for each wheel event associated with the scroll
to be processed to see if it will be canceled. In such cases the user
agent should generate wheel
events whose cancelable
property is false
, indicating that preventDefault
cannot be used to prevent or interrupt
scrolling. Otherwise cancelable
will be true
.
In particular, a user agent should generate only uncancelable wheel
events when it observes
that there are no non-passive listeners for the event.
4. Security Considerations
TODO - Add specific concerns for this spec
5. Acknowledgements
TODO
6. Refs to other UIEvent specs [DELETE]
This section will be deleted.
Temporary place to "define" other referenced UI Events (to make the bikeshed linker happy). This will be deleted once we have proper cross-references.
6.1. Things defined in other sections
6.1.1. Activation triggers and behavior
6.1.2. Composition Events
6.1.3. Default actions and cancelable events
6.1.4. Event dispatch and DOM event flow
6.1.5. Focus Events
6.1.6. Web browsers and other dynamic or interactive user agents
6.1.7. Authoring tools
7. Glossary [DELETE]
This section will be deleted.
Temporary glossary terms (for bikeshed linker). Many of these are properly defined elsewhere and should be linked to directly. Terms which should be defined in this spec should be defined inline.
- activation behavior
-
The action taken when an event, typically initiated by users through an input device, causes an element to fulfill a defined task. The task MAY be defined for that element by the host language, or by author-defined variables, or both. The default task for any given element MAY be a generic action, or MAY be unique to that element. For example, the activation behavior of an HTML or SVG
<a>
element is to cause the user agent to traverse the link specified in thehref
attribute, with the further optional parameter of specifying the browsing context for the traversal (such as the current window or tab, a named window, or a new window). The activation behavior of an HTML<input>
element with thetype
attribute valuesubmit
is be to send the values of the form elements to an author-defined IRI by the author-defined HTTP method. See § 6.1.1 Activation triggers and behavior for more details. - activation trigger
-
An event which is defined to initiate an activation behavior. Refer to § 6.1.1 Activation triggers and behavior for more details.
- default action
-
A default action is an OPTIONAL supplementary behavior that an implementation MUST perform in combination with the dispatch of the event object. Each event type definition, and each specification, defines the default action for that event type, if it has one. An instance of an event MAY have more than one default action under some circumstances, such as when associated with an activation trigger. A default action MAY be cancelled through the invocation of the
preventDefault()
method. For more details, see § 6.1.3 Default actions and cancelable events. - delta
-
The estimated scroll amount (in pixels, lines, or pages) that the user agent will scroll or zoom the page in response to the physical movement of an input device that supports the
WheelEvent
interface (such as a mouse wheel or touch pad). The value of a delta (e.g., thedeltaX
,deltaY
, ordeltaZ
attributes) is to be interpreted in the context of the currentdeltaMode
property. The relationship between the physical movement of a wheel (or other device) and whether the delta is positive or negative is environment and device dependent. However, if a user agent scrolls as the default action then the sign of the delta is given by a right-hand coordinate system where positive X,Y, and Z axes are directed towards the right-most edge, bottom-most edge, and farthest depth (away from the user) of the document, respectively. - event
-
An event is the representation of some occurrence (such as a mouse click on the presentation of an element, the removal of child node from an element, or any number of other possibilities) which is associated with its event target. Each event is an instantiation of one specific event type.
- event target
-
The object to which an event is targeted using the § 6.1.4 Event dispatch and DOM event flow. The event target is the value of the
target
attribute. - host language
-
Any language which integrates the features of another language or API specification, while normatively referencing the origin specification rather than redefining those features, and extending those features only in ways defined by the origin specification. An origin specification typically is only intended to be implemented in the context of one or more host languages, not as a standalone language. For example, XHTML, HTML, and SVG are host languages for UI Events, and they integrate and extend the objects and models defined in this specification.
- rotation
-
An indication of incremental change on an input device using the
WheelEvent
interface. On some devices this MAY be a literal rotation of a wheel, while on others, it MAY be movement along a flat surface, or pressure on a particular button. - topmost event target
-
The topmost event target MUST be the element highest in the rendering order which is capable of being an event target. In graphical user interfaces this is the element under the user’s pointing device. A user interface’s
hit testing
facility is used to determine the target. For specific details regarding hit testing and stacking order, refer to the host language. - un-initialized value
-
The value of any event attribute (such as
bubbles
orcurrentTarget
) before the event has been initialized withinitEvent()
. The un-initialized values of an event apply immediately after a new event has been created using the methodcreateEvent()
. - user agent
-
A program, such as a browser or content authoring tool, normally running on a client machine, which acts on a user’s behalf in retrieving, interpreting, executing, presenting, or creating content. Users MAY act on the content using different user agents at different times, for different purposes. See the § 6.1.6 Web browsers and other dynamic or interactive user agents and § 6.1.7 Authoring tools for details on the requirements for a conforming user agent.
- Window
-
The
Window
is the object referred to by the current document’s browsing context’s Window Proxy object as defined in HTML5 [HTML5].