-
Notifications
You must be signed in to change notification settings - Fork 290
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Allow touch scroll to be default prevented by making the handlers passive #423
Changes from 3 commits
0d3a5f6
a86b63f
fb83c2b
803faaf
6db0796
4127040
07a376f
44a1411
3499535
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -456,11 +456,18 @@ class FixedDataTable extends React.Component { | |
} | ||
|
||
componentWillUnmount() { | ||
// TODO (pradeep): Remove these and pass to our table component directly after | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Here's the related issue if you want to reference it: There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. thanks, will put. |
||
// React provides an API where event handlers can be specified to be non-passive | ||
this._divRef && this._divRef.removeEventListener( | ||
'wheel', | ||
this._wheelHandler.onWheel, | ||
{ passive: false } | ||
); | ||
this._divRef && this._divRef.removeEventListener( | ||
'touchmove', | ||
this._touchHandler.onTouchMove, | ||
{ passive: false } | ||
); | ||
this._wheelHandler = null; | ||
this._touchHandler = null; | ||
|
||
|
@@ -576,6 +583,11 @@ class FixedDataTable extends React.Component { | |
this._wheelHandler.onWheel, | ||
{ passive: false } | ||
); | ||
this._divRef && this._divRef.addEventListener( | ||
'touchmove', | ||
this._touchHandler.onTouchMove, | ||
{ passive: false } | ||
); | ||
this._reportContentHeight(); | ||
} | ||
|
||
|
@@ -798,7 +810,6 @@ class FixedDataTable extends React.Component { | |
onKeyDown={this._onKeyDown} | ||
onTouchStart={this._touchHandler.onTouchStart} | ||
onTouchEnd={this._touchHandler.onTouchEnd} | ||
onTouchMove={this._touchHandler.onTouchMove} | ||
onTouchCancel={this._touchHandler.onTouchCancel} | ||
ref={this._onRef} | ||
style={{ | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -148,6 +148,7 @@ class ReactTouchHandler { | |
} | ||
|
||
onTouchMove(/*object*/ event) { | ||
event.preventDefault(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. if the delta is zero, There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Will this lead to the issue where you can't scroll the parent page with your pointer over the grid? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @wcjordan , Yes exactly. My reasoning was that I wouldn't want to scroll any container if the cursor is on the table. But now I agree, that it's better to have a FF control this instead (#419 (comment)). Will add |
||
|
||
var moveX = event.touches[0].pageX; | ||
var moveY = event.touches[0].pageY; | ||
|
@@ -175,8 +176,6 @@ class ReactTouchHandler { | |
this._deltaY = 0; | ||
} | ||
|
||
event.preventDefault(); | ||
|
||
// Ensure minimum delta magnitude is met to avoid jitter | ||
var changed = false; | ||
if (Math.abs(this._deltaX) > 2 || Math.abs(this._deltaY) > 2) { | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -64,6 +64,8 @@ class ReactWheelHandler { | |
} | ||
|
||
onWheel(/*object*/ event) { | ||
event.preventDefault(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Will this lead to the issue where you can't scroll the parent page with your pointer over the grid? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yep, same as above. |
||
|
||
var normalizedEvent = normalizeWheel(event); | ||
|
||
// if shift is held, swap the axis of scrolling. | ||
|
@@ -85,7 +87,6 @@ class ReactWheelHandler { | |
|
||
this._deltaX += handleScrollX ? normalizedEvent.pixelX : 0; | ||
this._deltaY += handleScrollY ? normalizedEvent.pixelY : 0; | ||
event.preventDefault(); | ||
|
||
var changed; | ||
if (this._deltaX !== 0 || this._deltaY !== 0) { | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Typo.. It worked anyway, so I guess React was being lenient.