Jquery Panzoom zoom with focal not working

1.3k Views Asked by At

I'm using Panzoom (https://github.com/timmywil/jquery.panzoom) to zoom and pan on an image. When I try to use the 'focal' parameter to zoom in to a specific point, the first step does not seem to respect this value.

Here is how I init panzoom:

$panzoom = $(container).panzoom({
    panOnlyWhenZoomed: true,
    minScale: minScale,
    maxScale: maxScale,
    contain: 'invert',
    exponential: app.panZoom.exponential,
    increment: 0.5,
    transition: true,
    duration: 500,
    startTransform: 'scale(' + minScale + ')'
});

If I call the following on a click event:

$(container).panzoom("zoom", {
    increment: 0.5,
    animate: true,
    focal: {
        clientX: 10,
        clientY: 10
    }
});

The first time will zoom toward the center and the next ones will actually zoom to (10, 10).

Other people had this issue (https://github.com/timmywil/jquery.panzoom/issues/297) but they didn't find any solution yet.

0

There are 0 best solutions below