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

fix(ui): zoom in and out from cursor position #262

Merged

Conversation

rob-gordon
Copy link
Contributor

@rob-gordon rob-gordon commented Feb 2, 2022

This fixes the odd zooming behavior in the studio
react-storm-diagram had some errors in how it processed non-integer zoom levels

To create a smooth zoom we

  • store our own floating point zoom value and only pass the rounded version to react-storm
  • we control the version we pass by hijacking the wheel handler that manages zooming in and out
  • zoom imperatively rather than effectually – this just means that we're zooming first and then updating the zoom level we keep in redux state. trying to zoom as an effect of the redux state also may have been getting react-storm out of sync. As a result, there's a few actions and reducers we no longer needed

I changed the minimum zoom to 25 rather than 10 because 10 seemed comically small and 25 was the smallest value in out select in the interface. I also set a reasonable maximum (again, from the select). Happy to change or remove this functionality if people see fit.

Before

Screen.Recording.2022-02-02.at.3.28.19.PM.mov

After

Screen.Recording.2022-02-02.at.2.54.10.PM.mov

@linear
Copy link

linear bot commented Feb 2, 2022

DEV-1223 [FEATURE] Flow Editor Zoom Scroll

Is your feature request related to a problem? Please describe.
When working with large flows, the flow-editor gives us a "birds-eye view" of the flow, which tends to make the nodes very small and unreadable.

Also, the current mouse scroll-in implementation isn't super friendly.

Describe the solution you'd like
I've thought of a few ideas, but I'm definitely open to more.

  • Show the top left corner 100% zoom when opening a flow
  • Have the flow show the birds-eye view once opened, then pan-zoom over a few milliseconds into the top left corner to 100%

Describe alternatives you've considered
Alternatively, and probably the better solution would be to fix the scroll in implementation

  1. Increase the zoom % per mouse scroll tick. It is currently at 1%, and it takes a long time to reach the desired zoom level (configurable?)
  2. Fix the zoom-in of the flow to properly match the cursor position. Currently seems to favor an up and right-side zoom-in. (should be centered on the cursor)

Additional context
image

Copy link
Contributor

@laurentlp laurentlp left a comment

Choose a reason for hiding this comment

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

Nice work! Really good cleanup! 💪

I have found a single small issue, but otherwise, it looks fine to me

simplescreenrecorder-2022-02-02_19.09.40.mp4

Copy link
Contributor

@laurentlp laurentlp left a comment

Choose a reason for hiding this comment

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

Tested and working perfectly! Awesome work as usual!

@rob-gordon rob-gordon merged commit 6ed8110 into master Feb 7, 2022
@rob-gordon rob-gordon deleted the robgordon-dev-1223-feature-flow-editor-zoom-scroll branch February 7, 2022 15:21
laurentlp added a commit that referenced this pull request Feb 7, 2022
* fix(ui): zoom in and out from cursor position (#262)

* fix(ui): zoom in and out from cursor position

* fix(ui): zoom to fit

Co-authored-by: Samuel Massé <samuelmasse4@gmail.com>
Co-authored-by: Laurent Leclerc-Poulin <laurentleclercpoulin@gmail.com>

* chore(formatting): run prettier

Co-authored-by: Samuel Massé <samuelmasse4@gmail.com>
Co-authored-by: Laurent Leclerc-Poulin <laurentleclercpoulin@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants