blob: 466b79a374fa7cc63c9c83f19cebbbdfa96f78cc [file] [log] [blame]
// Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
class $CLASSNAME$EXTENDS$IMPLEMENTS$NATIVESPEC {
$!MEMBERS
$if DART2JS
/** @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 < 100) {
return detail * 40;
}
return detail;
}
return 0;
}
throw new UnsupportedError(
'deltaY is not supported');
}
/** @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');
}
int get deltaMode {
if (JS('bool', '!!#.deltaMode', this)) {
// If not available then we're poly-filling and doing pixel scroll.
return 0;
}
return this._deltaMode;
}
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);
int get _deltaMode => JS('int', '#.deltaMode', this);
$else
/** @domName WheelEvent.deltaX */
num get deltaX => $dom_wheelDeltaX;
/** @domName WheelEvent.deltaY */
num get deltaY => $dom_wheelDeltaY;
/** @domName WheelEvent.deltaMode */
int get deltaMode => 0;
$endif
}