Reputation: 3358
I am working with the svg-edit
for my project, and am altering the svgedit.compiled.js
as per my need, here am getting some issues, want to get the selected elements transform
which is in the transform matrix
,I can get the transform
of the the selected element in svg.
My code to get the current transform
if the element is follow
var my_selected= selectedElements[0].id;
//alert(my_selected);
var child_sel=$('#'+my_selected).children("g").attr('id');
var child_each=$('#'+my_selected);
//console.log(child_each);
child_each.each(function () {
var child_trans = $(this).attr('transform');
/* dx_x = x - start_x;
dy_x = y - start_y; */
$(this).children('g').each(function() {
if(this.id!='drag_drop') {
var test_x = $(this).attr('transform');
console.log(test_x);
var ss=this.getCTM();
console.log(ss);
}
});
});
But on the console.log(test_x);
am getting the value as matrix(0, 0.722035, -0.51, 0, 1561, 776.524)
on the next line am getting the same elements transform
by using this.getCTM()
but it not getting the previous value instead of it am getting below values
rotation : 90
scaleX : 0.7220349907875061
scaleY : 0.5099999904632568
skewX : 90
skewY : 90
translateX : 4060
translateY : 2376.5234375
What am doing wrong here? any clue on this ?
Upvotes: -1
Views: 865
Reputation: 6615
I am going off of memory here, but when the values were off by a very small amount, it was because of the border. I believe it is because getCTM does not take the border width into consideration but the transform matrix does, or vice versa. Try getScreenCTM or element.clientX if it exists.
Please create a fiddle demonstrating the problem for more help.
Upvotes: 0