Add more customization for auto pan #195
Open
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Following the closure of #183 because of the change of the
master
branch tomain
, I recreate this PR as-is, original text follows: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:
autoPanProps.length
: length of the auto pan area on each sideautoPanProps.width
: length of the auto pan area on the left and right, overrideslength
autoPanProps.height
: length of the auto pan area on the top and bottom, overrideslength
autoPanProps.delta
: amount of pixel to shift when auto panningautoPanProps.easing
: easing function which must return the amount of pixel to shift given t [0, 1], 0 being the start of the panning area, 1 being the edge of the viewer, overridesdelta
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
toACTION_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 withnpm link
orfile://
in package.json.Don't hesitate to give me a lot of feedback about any issue with these changes (especially
ACTION_AUTO_PAN
) as I am really keen to get these behaviors in! :)