Skip to content

Commit

Permalink
Move Mousewheel Event Type Detection to BrowserConstants (facebook#11585
Browse files Browse the repository at this point in the history
)
  • Loading branch information
cristidrg committed Nov 19, 2017
1 parent 01a867b commit 545cd45
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 12 deletions.
5 changes: 4 additions & 1 deletion packages/react-dom/src/events/BrowserEventConstants.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
*/

import getVendorPrefixedEventName from './getVendorPrefixedEventName';
import isEventSupported from './isEventSupported';

/**
* Types of raw signals from the browser caught at the top level.
Expand Down Expand Up @@ -85,7 +86,9 @@ var topLevelTypes = {
getVendorPrefixedEventName('transitionend') || 'transitionend',
topVolumeChange: 'volumechange',
topWaiting: 'waiting',
topWheel: 'wheel',
topWheel: isEventSupported('wheel')
? 'wheel'
: isEventSupported('mousewheel') ? 'mousewhee' : 'DOMMouseScroll',
};

export type TopLevelTypes = $Enum<typeof topLevelTypes>;
Expand Down
12 changes: 1 addition & 11 deletions packages/react-dom/src/events/ReactBrowserEventEmitter.js
Original file line number Diff line number Diff line change
Expand Up @@ -123,17 +123,7 @@ export function listenTo(registrationName, contentDocumentHandle) {
for (var i = 0; i < dependencies.length; i++) {
var dependency = dependencies[i];
if (!(isListening.hasOwnProperty(dependency) && isListening[dependency])) {
if (dependency === 'topWheel') {
if (isEventSupported('wheel')) {
trapBubbledEvent('topWheel', 'wheel', mountAt);
} else if (isEventSupported('mousewheel')) {
trapBubbledEvent('topWheel', 'mousewheel', mountAt);
} else {
// Firefox needs to capture a different mouse scroll event.
// @see http://www.quirksmode.org/dom/events/tests/scroll.html
trapBubbledEvent('topWheel', 'DOMMouseScroll', mountAt);
}
} else if (dependency === 'topScroll') {
if (dependency === 'topScroll') {
trapCapturedEvent('topScroll', 'scroll', mountAt);
} else if (dependency === 'topFocus' || dependency === 'topBlur') {
trapCapturedEvent('topFocus', 'focus', mountAt);
Expand Down

0 comments on commit 545cd45

Please sign in to comment.