Obtain width in draggable function SVG.js -
Obtain width in draggable function SVG.js -
i know can obtain width or size function, i'm trying in moment of creation of draggable object.
i'm doing because need give grid effect element , create remain within drawable area.
here similar i'm trying do:
square = draw.rect(size, size).x(x).y(y).draggable(function(x, y){ var xend = x - x % size; var yend = y - y % size;  if(xend < 0)     xend = 0; if(yend < 0)     yend = 0;  if(xend > 1000)     xend = 1000 - width*;   homecoming { x: xend, y: yend }  });    the var * want get.
also great know how allow svg.js elements interact jquery, guess that's question.
edit: well, in fact need access other properties of element, if can't draggable element think should way create draggable? :( please help!
the solution (as nils said), utilize square.bbox function, example:
square = draw.rect(size, size).x(x).y(y).draggable(function(x, y){ var xend = x - x % size; var yend = y - y % size;  if(xend < 0)     xend = 0; if(yend < 0)     yend = 0;  if(xend > 1000)     xend = 1000 - square.bbox().width;   homecoming { x: xend, y: yend }  });    also, if want access element later can assign id square.attr('id','id_name') method , phone call using svg.get('id_name') method.
 svg.js 
 
Comments
Post a Comment