首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >jsPlumb和jQuery.PanZoom拖动问题

jsPlumb和jQuery.PanZoom拖动问题
EN

Stack Overflow用户
提问于 2014-08-17 22:56:18
回答 2查看 1.1K关注 0票数 1

我使用jquery.panzoom插件来缩放和平移jsPlumb图,所有的东西都在工作,但是当我缩放和拖动一个元素时,这个元素会远离指针!有没有人面临同样的问题?有人能帮我一下吗?谢谢

EN

回答 2

Stack Overflow用户

发布于 2016-03-11 09:36:38

查看此http://jsfiddle.net/a4v2guvt/

代码语言:javascript
复制
$panzoom.on('panzoomzoom', function (e, panzoom, scale) {
    jsPlumb.setZoom(scale);
});
票数 1
EN

Stack Overflow用户

发布于 2016-09-04 05:26:54

为了解决这个问题,我使用了jQueryUI/draggable而不是内置的:

代码语言:javascript
复制
var currentScale = 1;
$container.find(".diagram .item").draggable({
start: function(e){
  var pz = $container.find(".panzoom");
  //we need current scale factor to adjust coordinates of dragging element
  currentScale = pz.panzoom("getMatrix")[0];
  $(this).css("cursor","move");
  pz.panzoom("disable");//disable panzoom to avoid double offset
},
drag:function(e,ui){
  //fix scale issue
  ui.position.left = ui.position.left/currentScale;
  ui.position.top = ui.position.top/currentScale;
  if($(this).hasClass("jsplumb-connected"))
  {
    plumb.repaint($(this).attr('id'),ui.position);
  }
},
stop: function(e,ui){
  var nodeId = $(this).attr('id');
  plumb.repaint(nodeId,ui.position);
  $(this).css("cursor","");
  //enable panzoom back
  $container.find(".panzoom").panzoom("enable");
}
});

看看this demo

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/25350340

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档