I am new to svg and thought I would try snap svg. I have a group of circles that I drag and I want to get the coordinates of the group. I use getBBox () for this, but it does not work as I expected. I would expect getBBox () to update its x and y coordinates, but that doesn't seem to be the case. It seems simple, but I think something is missing. Here is the code
var lx = 0, ly = 0, ox = 0, oy = 0; moveFnc = function(dx, dy, x, y) { var thisBox = this.getBBox(); console.log(thisBox.x, thisBox.y, thisBox); lx = dx + ox; ly = dy + oy; this.transform('t' + lx + ',' + ly); } startFnc = function(x, y, e) { } endFnc = function() { ox = lx; oy = ly; console.log(this.getBBox()); }; var s = Snap("#svg"); var tgroup = s.group(); tgroup.add(s.circle(100, 150, 70), s.circle(200, 150, 70)); tgroup.drag(moveFnc, startFnc, endFnc);
jsfiddle is at http://jsfiddle.net/STpGe/2/
What am I missing? How to get group coordinates? Thanks.
landland
source share