chrvadala / react-svg-pan-zoom

:eyes: A React component that adds pan and zoom features to SVG
https://chrvadala.github.io/react-svg-pan-zoom/
MIT License
684 stars 126 forks source link

Add more customization for auto pan #183

Closed LouisBrunner closed 3 years ago

LouisBrunner commented 4 years ago

Thanks a lot for this great project!

One of the issue (the only really) I ran into when integrating this in our product is around the auto-pan feature. I wanted to be able to customize the zone where auto-pan is triggered and the amount of space it shifts. So I added a bunch of properties:

The default behavior is still the same and corresponds to autoPanProps={{length: 20, delta: 2}}.

Another change I included was around the action used by auto-pan, changing it from ACTION_PAN to ACTION_AUTO_PAN, which is a breaking-change, but I needed to be able to distinguish regular panning from auto-panning (as our SVG is draggable as well and I want to disable regular panning when that is going but not auto-panning).

Last but not least, I just added a prepare script to allow to use the repository with npm link or file:// in package.json.

Don't hesitate to give me a lot of feedback about issues with these changes (especially ACTION_AUTO_PAN) as I am really keen to get these behaviors in! :)

chrvadala commented 3 years ago

Hi, since I selected "main" branch as the new default branch (instead of master), GH closed this PR. Feel free to submit a new PR on the "main" branch.