0

Raphael library用来在我的应用程序中绘制和处理对象extjs。基本上我能够找到DRAG以下SET方法:

var set = paper.set();
set.push(
    paper.circle(200,200,65).attr({fill: "orange", stroke: "black"}),
    paper.text(200, 200, buttonText).attr({"font-size": 24, "font-weight": "bold", fill: "black"})
);    

set.data("myset", set);
set.data("position", [0,0]);
var current_position = [0,0];

set.drag(   
    function(dx, dy) {
        this.data('myset').transform("T" + (this.data("position")[0] + dx) + "," + (this.data("position")[1] + dy));
    current_position = [dx,dy];
    },

    function() {
        this.data('myset').data("position",
            [this.data("position")[0] += current_position[0],
             this.data("position")[1] += current_position[1]
            ]);
    }

);

我在 jsFiddle 中找到了这个小代码,并对其进行了一些修改以做我需要的事情。你可以在这里查看演示。当您通过单击一次来拖动项目时,一切都会正常工作。但问题是,当你doublclick在它上面几次和play with it/drag时,它开始跳来跳去。坐标乱了

你能帮我找出我的坐标在哪里弄乱了。谢谢

4

1 回答 1

0

我通过查看此示例修复了它:here

var paper = Raphael(0, 0, 500, 500);
var set = paper.set();
set.push(paper.circle(100,100,35), paper.circle(150,150,15));    
set.attr("fill", "orange");
set.data("myset", set);

set.drag(
    function(dx, dy, x, y, e) {
        this.data('myset').transform("T" + dx + "," + dy);
    },
    function(x, y, e) {},
    function(e) {}
);
于 2013-05-28T21:30:46.597 回答