-
-
Notifications
You must be signed in to change notification settings - Fork 418
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
Feature: Limit pan distance outside of canvas, e.g. maxPanRatio #476
Comments
The Either way, I think this should go through the feature pipeline. Thanks! |
Hi!, I need something like this ,I'm using panzoom with a video it's a pan formatted video and the content is only on the center and when I zoom I want only be able to pan on the pars with content, the thing is that I don't understand your solution, can you give me some more details? Thanks! |
I think this have enough votes to implement, and we can use the ratio option instead of hard pixel amount. In other words, only the given amount of the panzoom element will be allowed outside the container. |
@mherodev I found your solution quite decipherable - thanks for sharing! It's a great feature to include. |
Hi @timmywil, is there any progress on this feature? thanks in advance. |
What problem does this feature solve?
A user can pan the content outside of the canvas to the point that the content is no longer visible (and even multiple canvas-distances away from the origin), and it may be unintuitive for the user to get the content back inside the visible canvas.
Describe the solution you'd like
An option to provide a max pan distance which would be a proportion of the pannable content, e.g.
maxPanRatio: 0.9
representing 90% of the content can be outside of the canvas before panning in that direction is disabled.Describe alternatives you've considered
Unfortunately
contain
doesn't appear to resolve this as we don't want to limit the element to beinside
the canvas, andoutside
didn't seem to behave as expected for an element initially smaller than the canvas.I did try contextually enabling and disabling
contain: 'outside'
depending on zoom level, but it doesn't seem like that's quite supported. That would also be a reasonable solution otherwise.I have added logic that detects when the
event.detail.x
/event.detail.y
values are outside of a specified range and callingpan
to return them to the limit, but it feels a bit hacky and requires a bunch of un-throttled calculations.Additional context
Here's a snippet of code to give an example of the approach I took. I found it pretty difficult to reason about, so pardon how verbose and yet indecipherable it is. Also, we're in an untranspiled environment, so its var-city, among other things.
I do see that there have been issues related to this in the past. Would a PR be welcome, or is this a feature outside the scope of the native library?
The text was updated successfully, but these errors were encountered: