aboutsummaryrefslogtreecommitdiff
path: root/node_modules/react-dom/lib/SyntheticMouseEvent.js
diff options
context:
space:
mode:
Diffstat (limited to 'node_modules/react-dom/lib/SyntheticMouseEvent.js')
-rw-r--r--node_modules/react-dom/lib/SyntheticMouseEvent.js71
1 files changed, 71 insertions, 0 deletions
diff --git a/node_modules/react-dom/lib/SyntheticMouseEvent.js b/node_modules/react-dom/lib/SyntheticMouseEvent.js
new file mode 100644
index 000000000..e07e0e5c0
--- /dev/null
+++ b/node_modules/react-dom/lib/SyntheticMouseEvent.js
@@ -0,0 +1,71 @@
+/**
+ * Copyright 2013-present, Facebook, Inc.
+ * All rights reserved.
+ *
+ * This source code is licensed under the BSD-style license found in the
+ * LICENSE file in the root directory of this source tree. An additional grant
+ * of patent rights can be found in the PATENTS file in the same directory.
+ *
+ */
+
+'use strict';
+
+var SyntheticUIEvent = require('./SyntheticUIEvent');
+var ViewportMetrics = require('./ViewportMetrics');
+
+var getEventModifierState = require('./getEventModifierState');
+
+/**
+ * @interface MouseEvent
+ * @see http://www.w3.org/TR/DOM-Level-3-Events/
+ */
+var MouseEventInterface = {
+ screenX: null,
+ screenY: null,
+ clientX: null,
+ clientY: null,
+ ctrlKey: null,
+ shiftKey: null,
+ altKey: null,
+ metaKey: null,
+ getModifierState: getEventModifierState,
+ button: function (event) {
+ // Webkit, Firefox, IE9+
+ // which: 1 2 3
+ // button: 0 1 2 (standard)
+ var button = event.button;
+ if ('which' in event) {
+ return button;
+ }
+ // IE<9
+ // which: undefined
+ // button: 0 0 0
+ // button: 1 4 2 (onmouseup)
+ return button === 2 ? 2 : button === 4 ? 1 : 0;
+ },
+ buttons: null,
+ relatedTarget: function (event) {
+ return event.relatedTarget || (event.fromElement === event.srcElement ? event.toElement : event.fromElement);
+ },
+ // "Proprietary" Interface.
+ pageX: function (event) {
+ return 'pageX' in event ? event.pageX : event.clientX + ViewportMetrics.currentScrollLeft;
+ },
+ pageY: function (event) {
+ return 'pageY' in event ? event.pageY : event.clientY + ViewportMetrics.currentScrollTop;
+ }
+};
+
+/**
+ * @param {object} dispatchConfig Configuration used to dispatch this event.
+ * @param {string} dispatchMarker Marker identifying the event target.
+ * @param {object} nativeEvent Native browser event.
+ * @extends {SyntheticUIEvent}
+ */
+function SyntheticMouseEvent(dispatchConfig, dispatchMarker, nativeEvent, nativeEventTarget) {
+ return SyntheticUIEvent.call(this, dispatchConfig, dispatchMarker, nativeEvent, nativeEventTarget);
+}
+
+SyntheticUIEvent.augmentClass(SyntheticMouseEvent, MouseEventInterface);
+
+module.exports = SyntheticMouseEvent; \ No newline at end of file