From 5b2676b55a86d1abb3a24bfdb211bc0f68c6e2f9 Mon Sep 17 00:00:00 2001 From: Jason Williams Date: Mon, 11 Jun 2018 14:01:17 +0100 Subject: [PATCH 1/3] adding movementX and movementY into syntheticMouseEvent --- .../src/events/SyntheticMouseEvent.js | 21 +++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/packages/react-dom/src/events/SyntheticMouseEvent.js b/packages/react-dom/src/events/SyntheticMouseEvent.js index d1ff4b32a1777..43bd653fa51f5 100644 --- a/packages/react-dom/src/events/SyntheticMouseEvent.js +++ b/packages/react-dom/src/events/SyntheticMouseEvent.js @@ -8,6 +8,9 @@ import SyntheticUIEvent from './SyntheticUIEvent'; import getEventModifierState from './getEventModifierState'; +let previousScreenX = null; +let previousScreenY = null; + /** * @interface MouseEvent * @see http://www.w3.org/TR/DOM-Level-3-Events/ @@ -34,6 +37,24 @@ const SyntheticMouseEvent = SyntheticUIEvent.extend({ : event.fromElement) ); }, + movementX: function(event) { + if ('movementX' in event) { + return event.movementX; + } + + const screenX = previousScreenX; + previousScreenX = event.ScreenX; + return screenX ? event.screenX - screenX : 0; + }, + movementY: function(event) { + if ('movementY' in event) { + return event.movementY; + } + + const screenY = previousScreenY; + previousScreenY = event.screenY; + return screenY ? event.screenY - screenY : 0; + }, }); export default SyntheticMouseEvent; From 51bc4153a32065ca6121cd163094c2027c20eaeb Mon Sep 17 00:00:00 2001 From: Jason Williams Date: Mon, 11 Jun 2018 21:35:27 +0100 Subject: [PATCH 2/3] fixing case mistake --- packages/react-dom/src/events/SyntheticMouseEvent.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/react-dom/src/events/SyntheticMouseEvent.js b/packages/react-dom/src/events/SyntheticMouseEvent.js index 43bd653fa51f5..d3319ec487156 100644 --- a/packages/react-dom/src/events/SyntheticMouseEvent.js +++ b/packages/react-dom/src/events/SyntheticMouseEvent.js @@ -43,7 +43,7 @@ const SyntheticMouseEvent = SyntheticUIEvent.extend({ } const screenX = previousScreenX; - previousScreenX = event.ScreenX; + previousScreenX = event.screenX; return screenX ? event.screenX - screenX : 0; }, movementY: function(event) { From 2cff05501fccf5fc9277b089979f6b12231136f7 Mon Sep 17 00:00:00 2001 From: Nathan Hunzaker Date: Fri, 15 Jun 2018 09:05:48 -0400 Subject: [PATCH 3/3] Add test fixture for movementX/Y fields --- fixtures/dom/src/components/Header.js | 1 + fixtures/dom/src/components/fixtures/index.js | 3 ++ .../components/fixtures/mouse-events/index.js | 16 +++++++ .../fixtures/mouse-events/mouse-movement.js | 48 +++++++++++++++++++ 4 files changed, 68 insertions(+) create mode 100644 fixtures/dom/src/components/fixtures/mouse-events/index.js create mode 100644 fixtures/dom/src/components/fixtures/mouse-events/mouse-movement.js diff --git a/fixtures/dom/src/components/Header.js b/fixtures/dom/src/components/Header.js index 4a7b1513e66cb..c78eaa6abf40a 100644 --- a/fixtures/dom/src/components/Header.js +++ b/fixtures/dom/src/components/Header.js @@ -65,6 +65,7 @@ class Header extends React.Component { +