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

Pan working but not zoom #79

Open
waterbuckit opened this issue Nov 19, 2020 · 1 comment
Open

Pan working but not zoom #79

waterbuckit opened this issue Nov 19, 2020 · 1 comment

Comments

@waterbuckit
Copy link

Maybe this isn't necessarily an issue with the plugin, but I cannot seem to get zoom to work at all, panning works just fine? After reading through the other issues, I noticed that I was required to add a viewbox, which I did, but zoom still refuses to work? I have checked that the events are firing and sure enough, they are. Width and height are just 100% respectively.

let draw = SVG()
    .addTo(`#${svgId}`)
    .size(width, height);

imageContainer = draw
    .nested()
    .viewbox(0, 0, 100, 100)
    .panZoom({zoomMin : 1, zoomMax:20});
image = imageContainer.image(imagePath);
image
    .size(width,height);
@Fuzzyma
Copy link
Member

Fuzzyma commented Nov 19, 2020

svg.panzoom.js needs to be able to figure out the dimensions of your svg somehow and it needs a viewbox. If only a percentage size is given or none, it will try offsetWidth and offsetHeight. However, these are only defined, when the svg is the root svg.
So either set an absolute width and height or make sure you call panzoom on the outermost svg

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

2 participants