react / react-0.13.3 / examples / basic-commonjs / node_modules / reactify / node_modules / react-tools / src / browser / syntheticEvents / SyntheticMouseEvent.js
81155 views/**1* Copyright 2013-2014, Facebook, Inc.2* All rights reserved.3*4* This source code is licensed under the BSD-style license found in the5* LICENSE file in the root directory of this source tree. An additional grant6* of patent rights can be found in the PATENTS file in the same directory.7*8* @providesModule SyntheticMouseEvent9* @typechecks static-only10*/1112"use strict";1314var SyntheticUIEvent = require('SyntheticUIEvent');15var ViewportMetrics = require('ViewportMetrics');1617var getEventModifierState = require('getEventModifierState');1819/**20* @interface MouseEvent21* @see http://www.w3.org/TR/DOM-Level-3-Events/22*/23var MouseEventInterface = {24screenX: null,25screenY: null,26clientX: null,27clientY: null,28ctrlKey: null,29shiftKey: null,30altKey: null,31metaKey: null,32getModifierState: getEventModifierState,33button: function(event) {34// Webkit, Firefox, IE9+35// which: 1 2 336// button: 0 1 2 (standard)37var button = event.button;38if ('which' in event) {39return button;40}41// IE<942// which: undefined43// button: 0 0 044// button: 1 4 2 (onmouseup)45return button === 2 ? 2 : button === 4 ? 1 : 0;46},47buttons: null,48relatedTarget: function(event) {49return event.relatedTarget || (50event.fromElement === event.srcElement ?51event.toElement :52event.fromElement53);54},55// "Proprietary" Interface.56pageX: function(event) {57return 'pageX' in event ?58event.pageX :59event.clientX + ViewportMetrics.currentScrollLeft;60},61pageY: function(event) {62return 'pageY' in event ?63event.pageY :64event.clientY + ViewportMetrics.currentScrollTop;65}66};6768/**69* @param {object} dispatchConfig Configuration used to dispatch this event.70* @param {string} dispatchMarker Marker identifying the event target.71* @param {object} nativeEvent Native browser event.72* @extends {SyntheticUIEvent}73*/74function SyntheticMouseEvent(dispatchConfig, dispatchMarker, nativeEvent) {75SyntheticUIEvent.call(this, dispatchConfig, dispatchMarker, nativeEvent);76}7778SyntheticUIEvent.augmentClass(SyntheticMouseEvent, MouseEventInterface);7980module.exports = SyntheticMouseEvent;818283