Skip to content
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

add touch events for brush component #864

Closed
wants to merge 2 commits into from

Conversation

BrianRosamilia
Copy link

@BrianRosamilia BrianRosamilia commented Oct 9, 2020

Fixes #845

The fix seems fairly simple and I think covers all scenarios.

One thing to note: it's hard to DRY out this code into member functions because of the hooks that the event handlers rely on :O I could create local functions in the jsx expression itself to DRY it up a little bit, or use higher order member functions, but I figured that this PR is actually the simplest/best to at least get started on fixing this and get some feedback first since I am totally new to this project 😄

💥 Breaking Changes

  • none

🐛 Bug Fix

  • adds touch events for brush component

@coveralls
Copy link

coveralls commented Oct 10, 2020

Pull Request Test Coverage Report for Build 298488210

  • 0 of 11 (0.0%) changed or added relevant lines in 2 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage decreased (-0.3%) to 56.997%

Changes Missing Coverage Covered Lines Changed/Added Lines %
packages/visx-brush/src/BrushSelection.tsx 0 4 0.0%
packages/visx-brush/src/BaseBrush.tsx 0 7 0.0%
Totals Coverage Status
Change from base Build 148: -0.3%
Covered Lines: 1285
Relevant Lines: 2183

💛 - Coveralls

@sakulstra
Copy link
Contributor

sakulstra commented Nov 16, 2020

just wanted to report this as an issue, glad a fix is already on the way 👍

I could create local functions in the jsx expression itself to DRY it up a little bit

I'd personally prefer that as it makes the code easier to follow and is in line with how the non functional components handle it.

Copy link
Collaborator

@williaster williaster left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey @BrianRosamilia apologies for such a delay in reviewing this, we really appreciate the PR! 🙌

I had a couple suggestions here for DRY-ness, lmk what you think and I'll keep an eye out for any updates to merge this ASAP hopefully for the 1.3.0 release.

@@ -405,6 +405,19 @@ export default class BaseBrush extends React.Component<BaseBrushProps, BaseBrush
if (onMouseUp) onMouseUp(event);
dragEnd(event);
}}
onTouchStart={(event: MouseHandlerEvent) => {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

on thought I have here for DRY-ness is to update all of these to PointerEvent handlers, which are a combination of MouseEvents + TouchEvents introduced in [email protected]. so onMouseDown => onPointerDown, onMouseLeave => onPointerLeave, onMouseMove => onPointerMove. I think that MouseHandlerEvent will also need to be updated to support React.PointerEvent.

To avoid breaking changes we could could keep the props as onMouseXXX, but could consider also adding onPointerXXX handlers to match, and then deprecate onMouseXXX in a future 2.0 release. This would also require that we bump the react peerDependency in @visx/brush to ^16.4.0, which is theoretically breaking but I just checked @visx/drag (which brush relies on) and it already requires ^16.8.0 so I think technically @visx/brush should already actually be ^16.8.0.

cc @hshoff

@@ -120,6 +120,8 @@ export default class Drag extends React.Component<DragProps, DragState> {
height={height}
onMouseMove={this.handleDragMove}
onMouseUp={this.handleDragEnd}
onTouchMove={this.handleDragMove}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since this change Drag was re-implemented/re-factored to use the useDrag hook so there are unfortunately conflicts now. I think an easy change might be to simply update onMouseMove/onMouseUp to onPointerMove/onPointerUp, similar to my suggestion in @visx/brush

@@ -146,6 +148,15 @@ export default class BrushSelection extends React.Component<
onClick={event => {
if (onClick) onClick(event);
}}
onTouchStart={disableDraggingSelection ? undefined : dragStart}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same comment on remove these additions and updating the above mouse handlers to the pointer equivalents 👍

@williaster
Copy link
Collaborator

Hi @BrianRosamilia just wanted to ping this PR again to see if we can get it past the finish line, or if I should take over.

Thanks & happy New Year!

@RemaaBdair
Copy link
Contributor

@williaster we've been facing the same issue, and we need this pr to get approved and merged ASAP. Is there any way to speed things up?
Should we do the reviews in another pr?

@RemaaBdair
Copy link
Contributor

@williaster Hi again, i created a new pr to address the reviews if you could check it please: #1155
Thank you

@williaster
Copy link
Collaborator

This will be superseded by #1155

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Brush interaction not working on mobile
6 participants