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

feat(brush): add using widows move events with brush #1164

Merged
merged 21 commits into from
Jul 1, 2021

Conversation

d3x42
Copy link
Contributor

@d3x42 d3x42 commented Apr 14, 2021

The new param isUseWindowMoveEvents will allow window event listeners to control dragging move and end.

🚀 Enhancements

It's possible to move the cursor away from the brush area (and finish brushing there).

Related PR and issues:
PR: PR-1110
Issue: #1109

My goal here - in the "isUseWindowMoveEvents" mode handle all mouse movements and mouse up events on the Base Brush component level. If there are examples for BrushCorner in the gallery I could try to handle it too.

@d3x42 d3x42 changed the title feat(brush): add using widows move events with feat(brush): add using widows move events with brush Apr 14, 2021
@d3x42
Copy link
Contributor Author

d3x42 commented Apr 14, 2021

Oh, it seems that my linter didn't get all issues here. I'll provide lint fixes tomorrow.

@d3x42
Copy link
Contributor Author

d3x42 commented Apr 15, 2021

@williaster Ready for review. Thanks!

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 @d3x42 thanks for getting this started!

I had a few specific comments to start, and my main high-level question is whether we need to introduce isMovingBrushSelection and brushHandleChange, or whether we can simply use the existing isBrushing flag. If you could explain this design choice more it'd be helpful.

packages/visx-brush/package.json Outdated Show resolved Hide resolved
packages/visx-brush/src/BaseBrush.tsx Outdated Show resolved Hide resolved
packages/visx-brush/src/BaseBrush.tsx Outdated Show resolved Hide resolved
packages/visx-brush/src/BaseBrush.tsx Outdated Show resolved Hide resolved
packages/visx-brush/src/Brush.tsx Outdated Show resolved Hide resolved
packages/visx-brush/src/BrushHandle.tsx Outdated Show resolved Hide resolved
packages/visx-brush/src/BrushSelection.tsx Outdated Show resolved Hide resolved
packages/visx-drag/src/useDrag.ts Outdated Show resolved Hide resolved
packages/visx-drag/src/Drag.tsx Outdated Show resolved Hide resolved
packages/visx-brush/src/BaseBrush.tsx Outdated Show resolved Hide resolved
@d3x42
Copy link
Contributor Author

d3x42 commented Apr 17, 2021

Hey @d3x42 thanks for getting this started!

I had a few specific comments to start, and my main high-level question is whether we need to introduce isMovingBrushSelection and brushHandleChange, or whether we can simply use the existing isBrushing flag. If you could explain this design choice more it'd be helpful.

It was separated because I need to determine which event would be handled by the mouse move event listener (logic from move handlers in the child components slightly different). I think that I could use one enum variable instead of multiple boolean. Something like brushingType: Moving|Brushing|Resize_left|Resize_Right etc.

@d3x42
Copy link
Contributor Author

d3x42 commented Apr 19, 2021

@williaster It seems that I resolved all of your comments. Please check when you have time.

@d3x42 d3x42 requested a review from williaster April 26, 2021 12:02
@williaster
Copy link
Collaborator

Hey @d3x42 sorry for such a long delay, have been super slammed at work and out a bit on vacation. Will try to get this reviewed by end of week 🙏

@d3x42
Copy link
Contributor Author

d3x42 commented May 11, 2021

@williaster gentle ping

@williaster
Copy link
Collaborator

Hey @d3x42 thanks for the ping. I just pulled this branch locally to play with it functionally (by setting useWindowMoveEvents=true on the <Brush /> in the demo package) and there seem to be several issues still.

Cannot resize the brush
no-resize

Jumpy-ness when moving the brush on the track
It always jumps to the right side of the brush when you first move it
jumpy

Jumpy-ness when moving the brush outside the track
jumpy-window

How were you testing this functionally? I think these will need to be fixed before we can merge it, but thanks again for all the work on improving this 🙏

@d3x42
Copy link
Contributor Author

d3x42 commented May 13, 2021

It's strange. Resize works for me:
resize

@d3x42
Copy link
Contributor Author

d3x42 commented May 13, 2021

@williaster Sorry for the bug with jumping on move starts, it should be fine now.

Resize works fine for me. I checked it in chrome, firefox and safari on macOS. Could you add some details on your os, browser, and browser version to reproduce it?

@williaster
Copy link
Collaborator

Hey @d3x42 I pulled it again and it's no longer jumpy/works well when dragging outside of the svg 🎉.

Still can't resize tho, I tried it on chrome/firefox/safari and same behavior for each. I'm on macOS BigSur 11.3.1. I wanted to confirm that you were rebuilding both @visx/brush and @visx/drag locally when testing? It's a little confusing because the @visx/demo site seems to use the esm build for direct imports (brush) and non-esm builds for dependencies of those imports (drag).

So locally I was running yarn dev in the demo package, then rebuilding with two commands
yarn build:workspaces --workspaces=@visx/brush --esm
yarn build:workspaces --workspaces=@visx/drag

To verify, when yarn dev is running for @visx/demo I usually check that the next server re-compiles when running either of those.

@d3x42
Copy link
Contributor Author

d3x42 commented May 14, 2021

@williaster Thanks! After rebuilding @visx/drag without esm I was able to reproduce the issue. Fix already here.

@williaster
Copy link
Collaborator

williaster commented May 17, 2021

Hey @d3x42 I can resize now, but noticed a jumping issue during the transition between the svg/window. It seems to only happen on the left side.

May-17-2021 12-16-27

@d3x42
Copy link
Contributor Author

d3x42 commented May 19, 2021

@williaster I fixed jumpings on resizing and selection

@d3x42
Copy link
Contributor Author

d3x42 commented Jun 2, 2021

@weibohe Hi! Any news on the review for this PR?

@d3x42
Copy link
Contributor Author

d3x42 commented Jun 18, 2021

Merge master changes to branch.

@williaster could you please take a look on this pr?

@d3x42
Copy link
Contributor Author

d3x42 commented Jun 29, 2021

@williaster gentle ping

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 @d3x42 sorry for the delay on my end, I have been super busy but I appreciate the pings. I think this is close, just a couple more comments on my end for readability.

packages/visx-brush/src/BrushSelection.tsx Outdated Show resolved Hide resolved
packages/visx-brush/src/utils.ts Outdated Show resolved Hide resolved
packages/visx-brush/src/BaseBrush.tsx Outdated Show resolved Hide resolved
packages/visx-brush/src/BaseBrush.tsx Outdated Show resolved Hide resolved
packages/visx-brush/src/Brush.tsx Outdated Show resolved Hide resolved
packages/visx-brush/src/BrushHandle.tsx Outdated Show resolved Hide resolved
@williaster
Copy link
Collaborator

don't worry about happo failing, we are having some auth issues with it.

@williaster
Copy link
Collaborator

also played with it functionally and looks good, do you want to set useWindowEvents on the @visx/demo example so this is the default behavior there? 😄

d3x42 and others added 6 commits July 1, 2021 16:23
Co-authored-by: Chris Williams <williaster@users.noreply.github.com>
Co-authored-by: Chris Williams <williaster@users.noreply.github.com>
Co-authored-by: Chris Williams <williaster@users.noreply.github.com>
Co-authored-by: Chris Williams <williaster@users.noreply.github.com>
@d3x42
Copy link
Contributor Author

d3x42 commented Jul 1, 2021

also played with it functionally and looks good, do you want to set useWindowEvents on the @visx/demo example so this is the default behavior there? 😄

Sure! I'll update the demo. :)

@d3x42
Copy link
Contributor Author

d3x42 commented Jul 1, 2021

@d3x42 PR updated with your suggestions.) "isControlled" definitely way better for child components in Brush.

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.

Okay I think this is probably the final review. Sorry for multiple review rounds but this one is definitely more complex than some.

Thank you for all the hard work on this, it's a significant improvement to the current UX! 👏 I think after these changes we can merge this puppy! 🚢

packages/visx-brush/src/types.ts Outdated Show resolved Hide resolved
packages/visx-brush/src/BaseBrush.tsx Outdated Show resolved Hide resolved
packages/visx-brush/src/BaseBrush.tsx Outdated Show resolved Hide resolved
packages/visx-brush/src/BaseBrush.tsx Outdated Show resolved Hide resolved
@d3x42
Copy link
Contributor Author

d3x42 commented Jul 1, 2021

@williaster PR updated. Multiple reviews rounds fine for me, they really make this PR better.)

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.

Sweet, lgtm! 😍 Thank you again 🎉

@williaster williaster merged commit 123855a into airbnb:master Jul 1, 2021
@github-actions
Copy link

github-actions bot commented Jul 1, 2021

🎉 This PR is included in version v1.15.0 of the packages modified 🎉

@sakulstra
Copy link
Contributor

Hey, i saw this pr superseded #864 , but i'm pretty sure it doesn't.
as far as i know mouseMove will not fire on touchMove so on touch devices the brush is still not usable.
I think you can verify by visiting: https://airbnb.io/visx/brush

@williaster
Copy link
Collaborator

@sakulstra that's correct, this is being tracked in #845 . Fix is out now in #1286 .

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.

None yet

3 participants