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

Create <PanZoom> #244

Closed
6 tasks
techniq opened this issue Feb 19, 2018 · 3 comments
Closed
6 tasks

Create <PanZoom> #244

techniq opened this issue Feb 19, 2018 · 3 comments

Comments

@techniq
Copy link
Collaborator

techniq commented Feb 19, 2018

Just throwing this here so I don't forget about it (and document some ideas). It would be useful to have a <PanZoom> component to handle panning and zooming an SVG canvas for large visuals.

  • Programatic panning and zooming (support for directional arrow UI / keyboard input / focus on element)
  • Panning via mouse (grab and drag)
  • Mini-map
    • Using upcoming @vx/brush?
  • Setting explicit coordinates / zoom (pan/zoom to highlight specific area/item)
  • Support animations / smooth transitions
  • Make sure drag performance is good (sync on rAF?)

There is already a nice component that does a lot of this, but also includes it's own UI. I think we should provide the foundation to build something similar, but allow the user to build their own UI.

I currently have some progress here (see PanZoom2 which uses the new @vx/drag)

Additional zoom examples:

@JCQuintas
Copy link

I believe I've improved on the code that was inside your sandbox.

It seems extending Drag instead of Component improves performance a bit. But I didn't make any performance tests, only my own feeling.

Having Access to Drag dxand dy allows us to reset the center of the graph as well as the scale. It also enabled the creation of zoomTo, which enables setting a custom zoom and centerOn that allow moving to a specific coordinate.

You can check it out here: https://codesandbox.io/s/20mw1079zy

@JCQuintas
Copy link

JCQuintas commented Nov 27, 2018

Eventually I removed @vx/drag and implemented all of its methods since I had to re-center X and Y on pretty much every interaction for the zoom not to screw up. It's a working example and I didn't find any 'bugs' yet, but I feel it still might be too naive.

Ultimatelly I would preffer the drag/drop events to be used rather than click, but I couldn't make it work.

hshoff added a commit that referenced this issue Jan 31, 2019
@hshoff
Copy link
Member

hshoff commented Jan 31, 2019

should be fixed in: #418

@hshoff hshoff closed this as completed Jan 31, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants