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

Zoom limit not recalculated when container resizes #185

Closed
kevinlaw91 opened this issue Feb 17, 2016 · 3 comments
Closed

Zoom limit not recalculated when container resizes #185

kevinlaw91 opened this issue Feb 17, 2016 · 3 comments
Labels

Comments

@kevinlaw91
Copy link
Contributor

I have a page that automatically adjust SVG container size when window re-sizes. I also set the minZoom and maxZoom property for svgpanzoom.

I opened the page in a small window, when I re-size the window (e.g. maximize), the zoom limit does not gets recalculated uisng the newer, bigger container size. My artwork remain in a very small size even when fully zoomed in.

When I zoom in fully to the limit, and maximize a window from a small window...
What I expect:
Since container is bigger now, I can zoom in deeper, thus artwork can become bigger

What I see:
I cannot zoom in further.
It looks like the zoom level is restricted to the original container size, not the current size

If this sounds confusing, try to imagine if the original window/container size is 200x200, the artwork is fitted and sized to 200x200 when load. I can zoom for example 200% to 400x400 at max.
When I maximize the window/container to 1000x1000, I expect the artwork can zoom in to become 2000x2000 size, but it doesn't allow me to do so. The artwork is still fully zoomed in at 400x400 in a 1000x1000 container, I cannot zoom in futher.

This is fixed when I reload the page in maximized state. i.e., I can zoom in to 2000x2000 in maximized window with 1000x1000 container

@bumbu
Copy link
Owner

bumbu commented Feb 22, 2016

Did you try calling .resize() on svgPanZoom instance after browser resize? There is a demo with that.
If this doesn't help then please check provide a reproducible example https://github.com/ariutta/svg-pan-zoom#support with required steps.

@bumbu bumbu added the bug label Feb 22, 2016
@kevinlaw91
Copy link
Contributor Author

Hi @bumbu, I did call resize() but issue is still there. Was using the latest svgpanzoom v3.2.6 on chrome.

I found that it is hard to demo the bug using jsfiddle because we need fullscreen for comparison. I made a gist instead: https://gist.github.com/kevinlaw91/82d9b7d0ebf00c2120ca

You can download and run in browser, then use inspect element(docked) to trigger window resize event. I also created screenshot and steps on how to reproduce the bug:
issue185.pdf

@schurin
Copy link

schurin commented Feb 25, 2016

I have a similar problem.
Chrome: 48.0.2564.116 m
SvgPanZoom: 3.2.6
When I resize of the container, contents of the container does not fit, and extends beyond the boundaries.
The content is still the same size as it was before resize. I watched the zoom ratio before and after resize - _panZoom.getSizes().realZoom. And they were equal.
SvgPanZoom v3.2.3
We use this version.
Behavior to resize different from v3.2.6
When you resize the content to be fit.
But, when i call - _panZoom.zoomOut(), I'll get the content size before to resize
I'm use methods resize->fit->center when changing the size of the container.

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

No branches or pull requests

3 participants