File tree Expand file tree Collapse file tree 1 file changed +19
-4
lines changed
packages/react-dom/src/events Expand file tree Collapse file tree 1 file changed +19
-4
lines changed Original file line number Diff line number Diff line change 88import SyntheticUIEvent from './SyntheticUIEvent' ;
99import getEventModifierState from './getEventModifierState' ;
1010
11- let previousScreenX = null ;
12- let previousScreenY = null ;
11+ let previousScreenX = 0 ;
12+ let previousScreenY = 0 ;
13+ // Use flags to signal movementX/Y has already been set
14+ let isMovementXSet = false ;
15+ let isMovementYSet = false ;
1316
1417/**
1518 * @interface MouseEvent
@@ -44,7 +47,13 @@ const SyntheticMouseEvent = SyntheticUIEvent.extend({
4447
4548 const screenX = previousScreenX ;
4649 previousScreenX = event . screenX ;
47- return screenX ? event . screenX - screenX : 0 ;
50+
51+ if ( ! isMovementXSet ) {
52+ isMovementXSet = true ;
53+ return 0 ;
54+ }
55+
56+ return event . screenX - screenX ;
4857 } ,
4958 movementY : function ( event ) {
5059 if ( 'movementY' in event ) {
@@ -53,7 +62,13 @@ const SyntheticMouseEvent = SyntheticUIEvent.extend({
5362
5463 const screenY = previousScreenY ;
5564 previousScreenY = event . screenY ;
56- return screenY ? event . screenY - screenY : 0 ;
65+
66+ if ( ! isMovementYSet ) {
67+ isMovementYSet = true ;
68+ return 0 ;
69+ }
70+
71+ return event . screenY - screenY ;
5772 } ,
5873} ) ;
5974
You can’t perform that action at this time.
0 commit comments