我已经找到了如何使用 Raphael JS 拖动对象。
但是现在,我想知道是否可以调整动态打印文本的大小并使用 Raphael JS 获取此“对象”的新宽度/高度。
这是我想要完成的第一个视图:
$(function() {
var R = Raphael("holder", 400, 400);
$("#typetext").keyup(function() {
var textValue = $(this).val();
R.clear();
var c = R.print(100, 100, textValue, R.getFont("Arial"), 60).attr({
fill: "#ff0000",
cursor: "move"
});
var start = function() {
this.odx = 0;
this.ody = 0;
this.animate({
"fill-opacity": 0.2
}, 500);
},
move = function(dx, dy) {
this.translate(dx - this.odx, dy - this.ody);
this.odx = dx;
this.ody = dy;
},
up = function() {
this.animate({
"fill-opacity": 1
}, 500);
};
c.drag(move, start, up);
});
});
演示:http: //jsfiddle.net/ZuYcG/
任何建议将不胜感激!
编辑:这个小提琴给出了我需要做什么的想法,但带有印刷文本。
EDIT2:打印文本由SVG结构中的路径定义,似乎无法获得路径的宽度和高度......