Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/427.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript Raphael.js中带有transform()方法的可拖动路径_Javascript_Path_Drag And Drop_Raphael - Fatal编程技术网

Javascript Raphael.js中带有transform()方法的可拖动路径

Javascript Raphael.js中带有transform()方法的可拖动路径,javascript,path,drag-and-drop,raphael,Javascript,Path,Drag And Drop,Raphael,我正在尝试使用非弃用的方法Element.transform()拖动路径。下面是使用不推荐的方法Element.translate()的答案: 当我简单地用transform()替换translate()时,我的路径会很快回到初始位置: drag(function (dx, dy) { var trans_x = dx - this.ox; var trans_y = dy - this.oy; this.transform("t" + trans_

我正在尝试使用非弃用的方法
Element.transform()
拖动路径。下面是使用不推荐的方法
Element.translate()
的答案:

当我简单地用
transform()
替换
translate()
时,我的路径会很快回到初始位置:

drag(function (dx, dy) {
       var trans_x = dx - this.ox;
       var trans_y = dy - this.oy;

       this.transform("t" + trans_x + "," + trans_y);
       this.ox = dx;
       this.oy = dy;
     }, 
     function () {
       this.ox = 0;
       this.oy = 0;
     },
     function() {
     }
);
有什么想法吗?

我找到了解决办法

只需使用transform()的append语法,即.transform(“…t”+…+…)

下面是我的最终结果:

drag(function (dx, dy) {
       var trans_x = dx - this.ox;
       var trans_y = dy - this.oy;

       this.transform("...t" + trans_x + "," + trans_y); //Just change this line
       this.ox = dx;
       this.oy = dy;
     }, 
     function () {
       this.ox = 0;
       this.oy = 0;
     },
     function() {
     }
);
而且它工作得很好