Спасибо за ваш ответ! Поскольку я хотел использовать собственные анимации SVG, я нашел это решение (все еще не работает отлично). Это своего рода версия не существующего animateTransform (attributeName = "transform" type = "matrix")
ПРИМЕЧАНИЕ: я сохраняю преобразование svg для каждого элемента в group.transform, а group.transform.matrix() возвращает просто матрица преобразования этого элемента.
Я сначала добавить эти элементы к элементу я хочу анимировать:
<animateTransform id="canvTranslate" begin="indefinite" attributeName="transform" type="translate" to="" dur="1s" additive="sum" fill="freeze"/>
<animateTransform id="canvRotate" begin="indefinite" attributeName="transform" type="rotate" to="" dur="1s" additive="sum" fill="freeze"/>
<animateTransform id="canvScale" begin="indefinite" attributeName="transform" type="scale" to="" dur="1s" additive="sum" fill="freeze"/>
Тогда я сделать:
var tMatrix = transformation.matrix(); //this is the transformation i want to obtain
var cMatrix = group.transform.matrix(); //this is the actual CTM of the element
//getting the animations
var animTrans = document.getElementById('canvTranslate');
var animRotaz = document.getElementById('canvRotate');
var animScale = document.getElementById('canvScale');
//setting duration (it's got somewhere before)
animTrans.setAttribute('dur', duration/1000+'s');
animRotaz.setAttribute('dur', duration/1000+'s');
animScale.setAttribute('dur', duration/1000+'s');
//calculating the 'from' attribute
var transX = cMatrix.e;
var transY = cMatrix.f;
var scaleX = Math.sqrt(Math.pow(cMatrix.a, 2)+Math.pow(cMatrix.b, 2));
var rotate = Math.atan(cMatrix.c/cMatrix.d);
animTrans.setAttribute('from', transX+','+transY);
animRotaz.setAttribute('from', -rotate*180/Math.PI);
animScale.setAttribute('from', scaleX);
//end 'from'
//calculating the 'to' attribute to set
var transX = tMatrix.e;
var transY = tMatrix.f;
var scaleX = Math.sqrt(Math.pow(tMatrix.a, 2)+Math.pow(tMatrix.b, 2));
var rotate = Math.atan(tMatrix.c/tMatrix.d);
animTrans.setAttribute('to', transX+','+transY);
animRotaz.setAttribute('to', -rotate*180/Math.PI);
animScale.setAttribute('to', scaleX);
//end 'to'
animTrans.beginElement();
animRotaz.beginElement();
animScale.beginElement();
group.transform = transformation;
и, наконец, обновить преобразование атрибута элемента:
setTimeout(function(){ //i will change this somehow better :)
//this is a problematic step. with it animations work on Chrome, without it they work good on firefox and opera too
$(group).attr('transform', 'matrix('+tMatrix.a+','+tMatrix.b+','+tMatrix.c+','+tMatrix.d+','+tMatrix.e+','+tMatrix.f+')');
}, duration+100);
Этот последний шаг является проблематичным. Я не могу понять, почему с ним отлично работает в Chrome, в то время как анимация заканчивается гораздо более масштабируемой в Firefox и Opera (где не вызывается setTimeout работает отлично).