[英]Simple translate with snap.svg
I just started looking into animating svg graphics and it seems very complex. 我刚开始研究动画svg图形,看起来非常复杂。
Im stuck on a seemingly simple problem. 我陷入了一个看似简单的问题。 I want to animate a element to a new place, but i want to do it over the set time.
我想将元素设置为新地方的动画,但我想在设定的时间内完成。
When i change i try with my current code i get a matrix attribute that appears, but i am unable to modify it, Does anyone know how to animate a object from the left to the right of a set amount of time. 当我改变我尝试使用我当前的代码我得到一个矩阵属性出现,但我无法修改它,有没有人知道如何从设定的时间的左侧到右侧动画对象。
window.onload = function () {
var s = Snap(100, 100);
Snap.load("http://new.beresponsive.co.za/wp-content/themes/responsive/flatui/images/icons/responsive.svg", function (f) {
redSomething = f.select("#phone");
redSomething.hover(function () {
redSomething.animate({
'transform': 'matrix(3.333, -0.000, 0.000, 3.333, 66.667, 66.667)'
}, 2000);
});
s.append(f);
});
};
I think its feeling complicated, as you are using a matrix, and I don't see why you need that here. 我觉得它感觉很复杂,因为你正在使用矩阵,我不明白为什么你需要它。 The 'simple' solution would be just to do
“简单”的解决方案就是做
redSomething.animate({ transform: 't100,0' }, 2000);
In the string 't' = translate, and 100,0 is move x 100 to the right. 在字符串't'= translate中,100,0向右移动x 100。
Note, if you already have a transform applied, you could try adding the string on the end of the current one, but its a bit trickier if its rotated already or something and you want it to move right. 注意,如果你已经应用了一个变换,你可以尝试在当前结束时添加字符串,但是如果它已经旋转了或者你想让它向右移动它有点棘手。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.