Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
Download
81155 views
1
/**
2
* Copyright 2013-2014, Facebook, Inc.
3
* All rights reserved.
4
*
5
* This source code is licensed under the BSD-style license found in the
6
* LICENSE file in the root directory of this source tree. An additional grant
7
* of patent rights can be found in the PATENTS file in the same directory.
8
*
9
* @providesModule SyntheticWheelEvent
10
* @typechecks static-only
11
*/
12
13
"use strict";
14
15
var SyntheticMouseEvent = require('SyntheticMouseEvent');
16
17
/**
18
* @interface WheelEvent
19
* @see http://www.w3.org/TR/DOM-Level-3-Events/
20
*/
21
var WheelEventInterface = {
22
deltaX: function(event) {
23
return (
24
'deltaX' in event ? event.deltaX :
25
// Fallback to `wheelDeltaX` for Webkit and normalize (right is positive).
26
'wheelDeltaX' in event ? -event.wheelDeltaX : 0
27
);
28
},
29
deltaY: function(event) {
30
return (
31
'deltaY' in event ? event.deltaY :
32
// Fallback to `wheelDeltaY` for Webkit and normalize (down is positive).
33
'wheelDeltaY' in event ? -event.wheelDeltaY :
34
// Fallback to `wheelDelta` for IE<9 and normalize (down is positive).
35
'wheelDelta' in event ? -event.wheelDelta : 0
36
);
37
},
38
deltaZ: null,
39
40
// Browsers without "deltaMode" is reporting in raw wheel delta where one
41
// notch on the scroll is always +/- 120, roughly equivalent to pixels.
42
// A good approximation of DOM_DELTA_LINE (1) is 5% of viewport size or
43
// ~40 pixels, for DOM_DELTA_SCREEN (2) it is 87.5% of viewport size.
44
deltaMode: null
45
};
46
47
/**
48
* @param {object} dispatchConfig Configuration used to dispatch this event.
49
* @param {string} dispatchMarker Marker identifying the event target.
50
* @param {object} nativeEvent Native browser event.
51
* @extends {SyntheticMouseEvent}
52
*/
53
function SyntheticWheelEvent(dispatchConfig, dispatchMarker, nativeEvent) {
54
SyntheticMouseEvent.call(this, dispatchConfig, dispatchMarker, nativeEvent);
55
}
56
57
SyntheticMouseEvent.augmentClass(SyntheticWheelEvent, WheelEventInterface);
58
59
module.exports = SyntheticWheelEvent;
60
61