javascript - Draggable font on RaphaelJS -
javascript - Draggable font on RaphaelJS -
im trying create text added using print() draggable. i've found post code doesn't work - i've reposted fiddle - on chrome , ff text flies off screen. if set getbbox() parameter false works first drag then, on subsequent drags, mouse offset.
var w = document.body.clientwidth, h = document.body.clientheight, paper = raphael(0, 0, w, h); var font = paper.getfont("vegur"); var text = paper.print(20,20,"my dragable text",font,50); var start = function () { text.obb = text.getbbox(); }, move = function (dx, dy) { var bb = text.getbbox(true); // setting false works 1 time text.transform('...t'+[text.obb.x - bb.x + dx, text.obb.y - bb.y + dy]); }, = function () { }; text.drag(move, start, up);
figured out...
var start = function() { //get original position before transform var obb = this.getbbox(true); //get position after lastly transform var nbb = this.getbbox(false); //store difference this.ox = nbb.x - obb.x this.oy = nbb.y - obb.y; }, move = function(dx, dy) { //apply difference mouse moves this.transform('t' + [this.ox + dx, this.oy + dy]); }, = function() { };
javascript svg raphael
Comments
Post a Comment