Panzoom,在缩放时设置div位置以缩放焦点

时间:2017-02-09 09:42:37

标签: javascript jquery jquery.panzoom

我想直观地监视panzooom jquery插件中的缩放焦点。为了做到这一点,我想在与焦点相同的坐标上放置一个小的10x10 div,但不知何故它将它放在一个完全不同的位置。这是我的代码:

(仅发布相关部分)

$panzoom.panzoom("option", {
      contain: false,
      increment: 10,
      duration: 2000,
      animate: true,
      exponential: false,
      minScale: minScale,
      maxScale: maxScale,
      panOnlyWhenZoomed : false,
      focal: {
            clientX:  position.left,  //coordinates of an existing div. 
            clientY:  position.top
        }
    }); 

    $panzoom.panzoom('zoom');

    var d = document.getElementById('zoomcenter');
    d.style.left = position.left+'px';
    d.style.top = position.top+'px';   // I expect this div to be 
                                       // placed in the same position as the above, 
                                       // where I am zooming to. Instead it is placed 
                                       // somewhere totally different. 
                                       // probably affected by the transform Matrix. 
                                       // but not able to figure out why.

    var matrix = $panzoom.panzoom("getMatrix");

    console.debug("boxl:" + position.left + " boxt:" + position.top + " zcl:" + $('#zoomcenter').offset().left + " zct:" + $('#zoomcenter').offset().top + " Matrix:" + matrix.toString())


//returns this:
// boxl:986.6997680664062 boxt:343.0241394042969 zcl:692.1810302734375 zct:285.1896057128906 Matrix:1.6775,0,0,1.6775,-1133.01,-244.451

编辑:其他信息: - div zoomcenter具有绝对定位。 - $ panzoom.panzoom(' zoom')的位置不会影响结果。

0 个答案:

没有答案