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

Panning with rotated X-AXIS SVG #329

Open
tmeghe opened this issue Feb 23, 2019 · 4 comments
Open

Panning with rotated X-AXIS SVG #329

tmeghe opened this issue Feb 23, 2019 · 4 comments

Comments

@tmeghe
Copy link

tmeghe commented Feb 23, 2019

Hi,
Just a quick question which I didn't found any answer. I'm using the library with Angular 7 and it works well. However, for my need, the SVG I'm working on has a scale(1,-1) transform (equivalent to a rotateX(180deg))
When panning, everything is good on the X-AXIS but the panning behavior is inverted on the Y-AXIS. Is there a way to make it pan the right way ? (maybe intercepting the mouse coordinates and inverting them ?)
Any help appreciated, thanks a lot
Thomas

@bumbu
Copy link
Owner

bumbu commented Feb 23, 2019

You should be able to do that by using beforePan callback. You can read more about it on homepage https://github.com/ariutta/svg-pan-zoom .

@tmeghe
Copy link
Author

tmeghe commented Feb 24, 2019

Edit (previous answer was wrong) : Thanks for the answer, indeed I can access to pan values but panning is done through mouse so if I modify them I will loose the smooth panning translation ?

@bumbu
Copy link
Owner

bumbu commented Feb 25, 2019

Using this callback should not degrade performance of the panning (unless there CPU heavy computations in it, which I suppose there're not). If you can paste a jsfiddle - it may help understand the issue better.
Few other alternatives I can think of:

  • Before loading your SVG, modify it so to have scale(1, 1). Maybe an easy solution is to wrap everything in another element with scale(1, -1).
  • Use customEventsHandler (there're 2 demos on home page) - you'll have to write the behaviour of panning by yourself, but this way you'll have full control
  • Fork the library, add an option to it to support inverse axis, and compile.

Hopefully it helps

@shadowjustice
Copy link

I have a pull request #370 which is correct to add the rotate option to svg pan zoom. Then you can set the rotation. And as far as I know no effect on panning.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants