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

Limit boundary to image max? #105

Closed
kuzziemon opened this issue May 22, 2019 · 11 comments
Closed

Limit boundary to image max? #105

kuzziemon opened this issue May 22, 2019 · 11 comments

Comments

@kuzziemon
Copy link

Is it possible to limit zoom and pan to the image resolution?
I want to be able to zoom in and pan as if the boundaries are that of the image itself.

I've tried tinkering with the bounds option to no avail, so if I'm missing something blatantly obvious, please correct me.

@rbonomo
Copy link
Contributor

rbonomo commented May 23, 2019

Is this your problem?
https://codepen.io/rbonomo/pen/QRaRBN

Is this what you want?
https://codepen.io/rbonomo/pen/VOQwWZ
This pen uses the dist js in PR #106

@kuzziemon
Copy link
Author

Close, but no cigar. I need the limits of the boundaries to be the max of the ratio of height or width.

In the codepen you posted, it's limited to the size of image, rather than the size of the div. It is definitely one step closer to what I am looking for.

@rbonomo
Copy link
Contributor

rbonomo commented May 23, 2019

Can you post a codepen of what you have and I will get you where you want to go? I'm not understanding "limits of the boundaries to be the max of the ratio of height or width".

@kuzziemon
Copy link
Author

kuzziemon commented May 23, 2019

https://codepen.io/anon/pen/dEdqBR

Say I need the image to be size of a div that's 500x500 and the image itself is 3000x5000.
I need it to fit to the maximum side(in this case the height), so it will have bars on the side and prevent the panning until the image is zoomed in enough to allow space for panning up and down within the image itself.

@kuzziemon
Copy link
Author

The autocenter() function draws it perfectly.
I need whatever autocenter generates as the bounding box, but still allow zooming in and panning within that boundary.

Also, unrelated issue but it seems that there is something wrong with the animate() function when you use scroll wheel. I've noticed the same issue when using smoothZoom. It will get hung up on the animation and cause stuttering effects when used in quick succession.

@rbonomo
Copy link
Contributor

rbonomo commented May 26, 2019

Is this what you're looking for?
https://codepen.io/rbonomo/pen/BexEPR

Just a matter of CSS for that change.

@rbonomo
Copy link
Contributor

rbonomo commented May 26, 2019

@kuzziemon you'll probably have to call the kinetic.cancel() function before using any animate functions to prevent that from happening. Look in the source code.

@kuzziemon
Copy link
Author

I see, thanks for your help.
I've opted for another library with a bit more robust features, but this is still good to know as it still does apply.

@rbonomo
Copy link
Contributor

rbonomo commented Jun 4, 2019

@kuzziemon What library did you go forward with?

@bbugh
Copy link

bbugh commented Nov 23, 2020

@kuzziemon what library did you use?

@Andrew-web-coder
Copy link

The only one I could find is this one - https://fancyapps.com/docs/ui/panzoom/

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

4 participants