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

Scrolling across pandzoom content #211

Closed
ShakurOo opened this issue Oct 5, 2015 · 2 comments
Closed

Scrolling across pandzoom content #211

ShakurOo opened this issue Oct 5, 2015 · 2 comments

Comments

@ShakurOo
Copy link

ShakurOo commented Oct 5, 2015

Hello,

I would like scroll by swipping across the pandzoom content.

In my project the image has width: 100% of viewport, and when my Inch is on the pandzoom image, nothing appened, logic. But have you any tip for allow the scroll despite pandzoom ?

Example : When the image hasn't yet zoom ? when the image has zoom but the image is blocked by the limits of parent container ? When the scroll represent a certain percentage from bottom to top ?

Than'ks you

@kiddailey
Copy link

I needed this behavior as well. It would be nice if there was a flag "panOnlyWhenZoomed" that you could set that would allow you to swipe past panzoom when already at the minScale and only enable panning when zoomed in.

In the meantime you can fake the functionality pretty easily by checking whether the panzoom is scaled up past your minScale value and setting the disablePan accordingly. I tested this on iOS devices and in a variety of the Chrome device emulators and it seems to work fine:

// Set up panzoom container, making sure to disablePan by default
var $panzoom = $(".panzoom").panzoom({
    minScale: 1,
    disablePan: true
});

// After a zoom event, check zoomed state and reset the disablePanning
$panzoom.on('panzoomzoom', function(e, panzoom, scale, options) {
    $panzoom.panzoom("option", "disablePan", 
        Math.abs(scale - options.minScale) < 0.0001);
});

Edit: Tweaked it a bit to work in both properly in non-touch and made it a bit slimmer

@thomasfrobieter
Copy link

I agree. This function is very important, otherwise the lib is kinda useless .. especially on smaller touch devices.
It is not a very special case, that an image has 100% width on those devices and i think every end user will leave the page in case of being captured inside this image pan container :\

@lock lock bot locked as resolved and limited conversation to collaborators Aug 8, 2019
@timmywil timmywil removed the feature label Aug 9, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants