WheelEvent class
@DomName('WheelEvent')
class WheelEvent extends MouseEvent native "WheelEvent,MouseWheelEvent,MouseScrollEvent" {
factory WheelEvent(String type,
{Window view, int deltaX: 0, int deltaY: 0,
int detail: 0, int screenX: 0, int screenY: 0, int clientX: 0,
int clientY: 0, int button: 0, bool canBubble: true,
bool cancelable: true, bool ctrlKey: false, bool altKey: false,
bool shiftKey: false, bool metaKey: false, EventTarget relatedTarget}) {
if (view == null) {
view = window;
}
var eventType = 'WheelEvent';
if (Device.isFirefox) {
eventType = 'MouseScrollEvents';
}
final event = document.$dom_createEvent(eventType);
// If polyfilling, then flip these because we'll flip them back to match
// the W3C standard:
// http://dev.w3.org/2006/webapi/DOM-Level-3-Events/html/DOM3-Events.html#events-WheelEvent-deltaY
if (JS('bool', '#.deltaY === undefined', event)) {
deltaX = -deltaX;
deltaY = -deltaY;
}
if (event._hasInitWheelEvent) {
var modifiers = [];
if (ctrlKey) {
modifiers.push('Control');
}
if (altKey) {
modifiers.push('Alt');
}
if (shiftKey) {
modifiers.push('Shift');
}
if (metaKey) {
modifiers.push('Meta');
}
event._initWheelEvent(type, canBubble, cancelable, view, detail, screenX,
screenY, clientX, clientY, button, relatedTarget, modifiers.join(' '),
deltaX, deltaY, 0, 0);
} else if (event._hasInitMouseScrollEvent) {
var axis = 0;
var detail = 0;
if (deltaX != 0 && deltaY != 0) {
throw UnsupportedError(
'Cannot modify deltaX and deltaY simultaneously');
}
if (deltaY != 0) {
detail = deltaY;
axis = JS('int', 'MouseScrollEvent.VERTICAL_AXIS');
} else if (deltaX != 0) {
detail = deltaX;
axis = JS('int', 'MouseScrollEvent.HORIZONTAL_AXIS');
}
event._initMouseScrollEvent(type, canBubble, cancelable, view, detail,
screenX, screenY, clientX, clientY, ctrlKey, altKey, shiftKey,
metaKey, button, relatedTarget, axis);
} else {
// Fallthrough for Dartium.
event.$dom_initMouseEvent(type, canBubble, cancelable, view, detail,
screenX, screenY, clientX, clientY, ctrlKey, altKey, shiftKey,
metaKey, button, relatedTarget);
event.$dom_initWebKitWheelEvent(deltaX,
deltaY ~/ 120, // Chrome does an auto-convert to pixels.
view, screenX, screenY, clientX, clientY, ctrlKey, altKey, shiftKey,
metaKey);
}
return event;
}
@DomName('WheelEvent.DOM_DELTA_LINE')
@DocsEditable
static const int DOM_DELTA_LINE = 0x01;
@DomName('WheelEvent.DOM_DELTA_PAGE')
@DocsEditable
static const int DOM_DELTA_PAGE = 0x02;
@DomName('WheelEvent.DOM_DELTA_PIXEL')
@DocsEditable
static const int DOM_DELTA_PIXEL = 0x00;
@JSName('webkitDirectionInvertedFromDevice')
@DomName('WheelEvent.webkitDirectionInvertedFromDevice')
@DocsEditable
@SupportedBrowser(SupportedBrowser.CHROME)
@SupportedBrowser(SupportedBrowser.SAFARI)
@Experimental
final bool directionInvertedFromDevice;
@JSName('initWebKitWheelEvent')
@DomName('WheelEvent.initWebKitWheelEvent')
@DocsEditable
void $dom_initWebKitWheelEvent(int wheelDeltaX, int wheelDeltaY, Window view, int screenX, int screenY, int clientX, int clientY, bool ctrlKey, bool altKey, bool shiftKey, bool metaKey) native;
/**
* The amount that is expected to scroll vertically, in units determined by
* [deltaMode].
*
* See also:
*
* * [WheelEvent.deltaY](http://dev.w3.org/2006/webapi/DOM-Level-3-Events/html/DOM3-Events.html#events-WheelEvent-deltaY) from the W3C.
*/
@DomName('WheelEvent.deltaY')
num get deltaY {
if (JS('bool', '#.deltaY !== undefined', this)) {
// W3C WheelEvent
return this._deltaY;
} else if (JS('bool', '#.wheelDelta !== undefined', this)) {
// Chrome and IE
return -this._wheelDelta;
} else if (JS('bool', '#.detail !== undefined', this)) {
// Firefox
// Handle DOMMouseScroll case where it uses detail and the axis to
// differentiate.
if (JS('bool', '#.axis == MouseScrollEvent.VERTICAL_AXIS', this)) {
var detail = this._detail;
// Firefox is normally the number of lines to scale (normally 3)
// so multiply it by 40 to get pixels to move, matching IE & WebKit.
if (detail.abs() < 100) {
return -detail * 40;
}
return -detail;
}
return 0;
}
throw new UnsupportedError(
'deltaY is not supported');
}
/**
* The amount that is expected to scroll horizontally, in units determined by
* [deltaMode].
*
* See also:
*
* * [WheelEvent.deltaX](http://dev.w3.org/2006/webapi/DOM-Level-3-Events/html/DOM3-Events.html#events-WheelEvent-deltaX) from the W3C.
*/
@DomName('WheelEvent.deltaX')
num get deltaX {
if (JS('bool', '#.deltaX !== undefined', this)) {
// W3C WheelEvent
return this._deltaX;
} else if (JS('bool', '#.wheelDeltaX !== undefined', this)) {
// Chrome
return -this._wheelDeltaX;
} else if (JS('bool', '#.detail !== undefined', this)) {
// Firefox and IE.
// IE will have detail set but will not set axis.
// Handle DOMMouseScroll case where it uses detail and the axis to
// differentiate.
if (JS('bool', '#.axis !== undefined && '
'#.axis == MouseScrollEvent.HORIZONTAL_AXIS', this, this)) {
var detail = this._detail;
// Firefox is normally the number of lines to scale (normally 3)
// so multiply it by 40 to get pixels to move, matching IE & WebKit.
if (detail < 100) {
return -detail * 40;
}
return -detail;
}
return 0;
}
throw new UnsupportedError(
'deltaX is not supported');
}
@DomName('WheelEvent.deltaMode')
int get deltaMode {
if (JS('bool', '!!(#.deltaMode)', this)) {
return JS('int', '#.deltaMode', this);
}
// If not available then we're poly-filling and doing pixel scroll.
return 0;
}
num get _deltaY => JS('num', '#.deltaY', this);
num get _deltaX => JS('num', '#.deltaX', this);
num get _wheelDelta => JS('num', '#.wheelDelta', this);
num get _wheelDeltaX => JS('num', '#.wheelDeltaX', this);
num get _detail => JS('num', '#.detail', this);
bool get _hasInitMouseScrollEvent =>
JS('bool', '!!(#.initMouseScrollEvent)', this);
@JSName('initMouseScrollEvent')
void _initMouseScrollEvent(
String type,
bool canBubble,
bool cancelable,
Window view,
int detail,
int screenX,
int screenY,
int clientX,
int clientY,
bool ctrlKey,
bool altKey,
bool shiftKey,
bool metaKey,
int button,
EventTarget relatedTarget,
int axis) native;
bool get _hasInitWheelEvent =>
JS('bool', '!!(#.initWheelEvent)', this);
@JSName('initWheelEvent')
void _initWheelEvent(
String eventType,
bool canBubble,
bool cancelable,
Window view,
int detail,
int screenX,
int screenY,
int clientX,
int clientY,
int button,
EventTarget relatedTarget,
String modifiersList,
int deltaX,
int deltaY,
int deltaZ,
int deltaMode) native;
}
Extends
Interceptor > Event > UIEvent > MouseEvent > WheelEvent
Static Properties
Constructors
factory WheelEvent(String type, {Window view, int deltaX: 0, int deltaY: 0, int detail: 0, int screenX: 0, int screenY: 0, int clientX: 0, int clientY: 0, int button: 0, bool canBubble: true, bool cancelable: true, bool ctrlKey: false, bool altKey: false, bool shiftKey: false, bool metaKey: false, EventTarget relatedTarget}) #
factory WheelEvent(String type,
{Window view, int deltaX: 0, int deltaY: 0,
int detail: 0, int screenX: 0, int screenY: 0, int clientX: 0,
int clientY: 0, int button: 0, bool canBubble: true,
bool cancelable: true, bool ctrlKey: false, bool altKey: false,
bool shiftKey: false, bool metaKey: false, EventTarget relatedTarget}) {
if (view == null) {
view = window;
}
var eventType = 'WheelEvent';
if (Device.isFirefox) {
eventType = 'MouseScrollEvents';
}
final event = document.$dom_createEvent(eventType);
// If polyfilling, then flip these because we'll flip them back to match
// the W3C standard:
// http://dev.w3.org/2006/webapi/DOM-Level-3-Events/html/DOM3-Events.html#events-WheelEvent-deltaY
if (JS('bool', '#.deltaY === undefined', event)) {
deltaX = -deltaX;
deltaY = -deltaY;
}
if (event._hasInitWheelEvent) {
var modifiers = [];
if (ctrlKey) {
modifiers.push('Control');
}
if (altKey) {
modifiers.push('Alt');
}
if (shiftKey) {
modifiers.push('Shift');
}
if (metaKey) {
modifiers.push('Meta');
}
event._initWheelEvent(type, canBubble, cancelable, view, detail, screenX,
screenY, clientX, clientY, button, relatedTarget, modifiers.join(' '),
deltaX, deltaY, 0, 0);
} else if (event._hasInitMouseScrollEvent) {
var axis = 0;
var detail = 0;
if (deltaX != 0 && deltaY != 0) {
throw UnsupportedError(
'Cannot modify deltaX and deltaY simultaneously');
}
if (deltaY != 0) {
detail = deltaY;
axis = JS('int', 'MouseScrollEvent.VERTICAL_AXIS');
} else if (deltaX != 0) {
detail = deltaX;
axis = JS('int', 'MouseScrollEvent.HORIZONTAL_AXIS');
}
event._initMouseScrollEvent(type, canBubble, cancelable, view, detail,
screenX, screenY, clientX, clientY, ctrlKey, altKey, shiftKey,
metaKey, button, relatedTarget, axis);
} else {
// Fallthrough for Dartium.
event.$dom_initMouseEvent(type, canBubble, cancelable, view, detail,
screenX, screenY, clientX, clientY, ctrlKey, altKey, shiftKey,
metaKey, button, relatedTarget);
event.$dom_initWebKitWheelEvent(deltaX,
deltaY ~/ 120, // Chrome does an auto-convert to pixels.
view, screenX, screenY, clientX, clientY, ctrlKey, altKey, shiftKey,
metaKey);
}
return event;
}
Properties
final int $dom_clientX #
final int $dom_clientX
final int $dom_clientY #
final int $dom_clientY
final int $dom_screenX #
final int $dom_screenX
final int $dom_screenY #
final int $dom_screenY
final bool altKey #
true if the alt key was down when the mouse event was fired. Read only.
final bool altKey
final bool bubbles #
final bool bubbles
final int button #
final int button
final bool cancelable #
final bool cancelable
bool cancelBubble #
bool cancelBubble
final Point client #
@DomName('MouseEvent.clientX')
@DomName('MouseEvent.clientY')
Point get client => new Point($dom_clientX, $dom_clientY);
final bool ctrlKey #
true if the control key was down when the mouse event was fired. Read only.
final bool ctrlKey
final EventTarget currentTarget #
EventTarget get currentTarget => _convertNativeToDart_EventTarget(this._get_currentTarget);
final bool defaultPrevented #
event.preventDefault()
has been called on the event.
final bool defaultPrevented
final int deltaMode #
@DomName('WheelEvent.deltaMode')
int get deltaMode {
if (JS('bool', '!!(#.deltaMode)', this)) {
return JS('int', '#.deltaMode', this);
}
// If not available then we're poly-filling and doing pixel scroll.
return 0;
}
final num deltaX #
The amount that is expected to scroll horizontally, in units determined by deltaMode.
See also:
- WheelEvent.deltaX from the W3C.
@DomName('WheelEvent.deltaX')
num get deltaX {
if (JS('bool', '#.deltaX !== undefined', this)) {
// W3C WheelEvent
return this._deltaX;
} else if (JS('bool', '#.wheelDeltaX !== undefined', this)) {
// Chrome
return -this._wheelDeltaX;
} else if (JS('bool', '#.detail !== undefined', this)) {
// Firefox and IE.
// IE will have detail set but will not set axis.
// Handle DOMMouseScroll case where it uses detail and the axis to
// differentiate.
if (JS('bool', '#.axis !== undefined && '
'#.axis == MouseScrollEvent.HORIZONTAL_AXIS', this, this)) {
var detail = this._detail;
// Firefox is normally the number of lines to scale (normally 3)
// so multiply it by 40 to get pixels to move, matching IE & WebKit.
if (detail < 100) {
return -detail * 40;
}
return -detail;
}
return 0;
}
throw new UnsupportedError(
'deltaX is not supported');
}
final num deltaY #
The amount that is expected to scroll vertically, in units determined by deltaMode.
See also:
- WheelEvent.deltaY from the W3C.
@DomName('WheelEvent.deltaY')
num get deltaY {
if (JS('bool', '#.deltaY !== undefined', this)) {
// W3C WheelEvent
return this._deltaY;
} else if (JS('bool', '#.wheelDelta !== undefined', this)) {
// Chrome and IE
return -this._wheelDelta;
} else if (JS('bool', '#.detail !== undefined', this)) {
// Firefox
// Handle DOMMouseScroll case where it uses detail and the axis to
// differentiate.
if (JS('bool', '#.axis == MouseScrollEvent.VERTICAL_AXIS', this)) {
var detail = this._detail;
// Firefox is normally the number of lines to scale (normally 3)
// so multiply it by 40 to get pixels to move, matching IE & WebKit.
if (detail.abs() < 100) {
return -detail * 40;
}
return -detail;
}
return 0;
}
throw new UnsupportedError(
'deltaY is not supported');
}
final int detail #
final int detail
final int eventPhase #
final int eventPhase
final int hashCode #
Get a hash code for this object.
All objects have hash codes. Hash codes are guaranteed to be the
same for objects that are equal when compared using the equality
operator ==. Other than that there are no guarantees about
the hash codes. They will not be consistent between runs and
there are no distribution guarantees.
If a subclass overrides hashCode it should override the
equality operator as well to maintain consistency.
int get hashCode => Primitives.objectHashCode(this);
final Point layer #
@DomName('UIEvent.layerX')
@DomName('UIEvent.layerY')
Point get layer => new Point($dom_layerX, $dom_layerY);
final bool metaKey #
true if the meta key was down when the mouse event was fired. Read only.
final bool metaKey
final Point movement #
@DomName('MouseEvent.movementX')
@DomName('MouseEvent.movementY')
@SupportedBrowser(SupportedBrowser.CHROME)
@SupportedBrowser(SupportedBrowser.SAFARI)
@Experimental
Point get movement => new Point($dom_webkitMovementX, $dom_webkitMovementY);
final Point offset #
The coordinates of the mouse pointer in target node coordinates.
This value may vary between platforms if the target node moves after the event has fired or if the element has CSS transforms affecting it.
Point get offset {
if (JS('bool', '!!#.offsetX', this)) {
var x = JS('int', '#.offsetX', this);
var y = JS('int', '#.offsetY', this);
return new Point(x, y);
} else {
// Firefox does not support offsetX.
var target = this.target;
if (!(target is Element)) {
throw new UnsupportedError(
'offsetX is only supported on elements');
}
return (this.client -
this.target.getBoundingClientRect().topLeft).toInt();
}
}
final Point page #
@DomName('UIEvent.pageX')
@DomName('UIEvent.pageY')
Point get page => new Point($dom_pageX, $dom_pageY);
final EventTarget relatedTarget #
EventTarget get relatedTarget => _convertNativeToDart_EventTarget(this._get_relatedTarget);
final Type runtimeType #
A representation of the runtime type of the object.
Type get runtimeType => getRuntimeType(this);
final Point screen #
@DomName('MouseEvent.screenX')
@DomName('MouseEvent.screenY')
Point get screen => new Point($dom_screenX, $dom_screenY);
final bool shiftKey #
true if the shift key was down when the mouse event was fired. Read only.
final bool shiftKey
final EventTarget target #
EventTarget get target => _convertNativeToDart_EventTarget(this._get_target);
final String type #
final String type
final WindowBase view #
WindowBase get view => _convertNativeToDart_Window(this._get_view);
Operators
bool operator ==(other) #
The equality operator.
The default behavior for all Objects is to return true if and
only if this and
other are the same object.
If a subclass overrides the equality operator it should override
the hashCode method as well to maintain consistency.
bool operator ==(other) => identical(this, other);
Methods
dynamic noSuchMethod(Invocation invocation) #
noSuchMethod is invoked when users invoke a non-existant method
on an object. The name of the method and the arguments of the
invocation are passed to noSuchMethod in an Invocation.
If noSuchMethod returns a value, that value becomes the result of
the original invocation.
The default behavior of noSuchMethod is to throw a
noSuchMethodError.
dynamic noSuchMethod(Invocation invocation) {
throw new NoSuchMethodError(
this,
_symbolToString(invocation.memberName),
invocation.positionalArguments,
_symbolMapToStringMap(invocation.namedArguments));
}
void preventDefault() #
@DomName('Event.preventDefault')
@DocsEditable
void preventDefault() native;
void stopImmediatePropagation() #
@DomName('Event.stopImmediatePropagation')
@DocsEditable
void stopImmediatePropagation() native;
void stopPropagation() #
@DomName('Event.stopPropagation')
@DocsEditable
void stopPropagation() native;
String toString() #
Returns a string representation of this object.
String toString() => Primitives.objectToString(this);
void $dom_initEvent(String eventTypeArg, bool canBubbleArg, bool cancelableArg) #
DocumentEvent interface.
@JSName('initEvent')
@DomName('Event.initEvent')
@DocsEditable
void $dom_initEvent(String eventTypeArg, bool canBubbleArg, bool cancelableArg) native;
void $dom_initMouseEvent(String type, bool canBubble, bool cancelable, Window view, int detail, int screenX, int screenY, int clientX, int clientY, bool ctrlKey, bool altKey, bool shiftKey, bool metaKey, int button, EventTarget relatedTarget) #
@DomName('MouseEvent.initMouseEvent')
@DocsEditable
void $dom_initMouseEvent(String type, bool canBubble, bool cancelable, Window view, int detail, int screenX, int screenY, int clientX, int clientY, bool ctrlKey, bool altKey, bool shiftKey, bool metaKey, int button, EventTarget relatedTarget) {
var relatedTarget_1 = _convertDartToNative_EventTarget(relatedTarget);
_$dom_initMouseEvent_1(type, canBubble, cancelable, view, detail, screenX, screenY, clientX, clientY, ctrlKey, altKey, shiftKey, metaKey, button, relatedTarget_1);
return;
}
void $dom_initUIEvent(String type, bool canBubble, bool cancelable, Window view, int detail) #
Initializes the UIEvent object.
Parameters
typeArg- The type of UI event.
canBubbleArg- Whether or not the event can bubble.
cancelableArg- Whether or not the event can be canceled.
viewArg- Specifies the
viewattribute value. This may benull. detailArg- Specifies the detail attribute value.
@JSName('initUIEvent')
@DomName('UIEvent.initUIEvent')
@DocsEditable
void $dom_initUIEvent(String type, bool canBubble, bool cancelable, Window view, int detail) native;
void $dom_initWebKitWheelEvent(int wheelDeltaX, int wheelDeltaY, Window view, int screenX, int screenY, int clientX, int clientY, bool ctrlKey, bool altKey, bool shiftKey, bool metaKey) #
@JSName('initWebKitWheelEvent')
@DomName('WheelEvent.initWebKitWheelEvent')
@DocsEditable
void $dom_initWebKitWheelEvent(int wheelDeltaX, int wheelDeltaY, Window view, int screenX, int screenY, int clientX, int clientY, bool ctrlKey, bool altKey, bool shiftKey, bool metaKey) native;
This page includes content from the
Mozilla Foundation that is graciously
licensed under a
Creative Commons: Attribution-Sharealike license.
Mozilla has no other association with Dart or dartlang.org. We
encourage you to improve the web by
contributing to
The Mozilla Developer Network.