在raphael js中缩放/变换后拖动

时间:2014-01-27 16:36:19

标签: javascript svg raphael svg-animate

我缩放后如何更正文字的轴?看起来鼠标指针对文本位置没有响应。但是在最初创建时,我可以根据鼠标指针拖放文本。这是我的示例项目的链接。

var paper = Raphael(document.getElementById("area"), 500, 500);
var attr = {"fill":"red","font-family": "arial", "font-size": "50px","cursor":"move"};
var text = paper.text(250, 250, "Some\nTEST").attr(attr);

start = function () {

    this.ox = parseFloat( this.attr("x") );
    this.oy = parseFloat( this.attr("y") );
},
move = function (dx, dy) {
    this.attr({x: this.ox + dx, y: this.oy + dy});
    this.odx = dx;
    this.ody = dy;
},
up = function () {
    this.attr({cursor:"move"});
};

text.drag(move, start, up);

$("button.fontsize-control").click(function(){
    var action = $(this).data("action");
    if( action == "down" ){
        text.transform("s.80...");
    }else{
        text.transform("s1.2...");
    }
});

jsfiddle Example

0 个答案:

没有答案