2016-04-29 12 views
1

Ich versuche, meine SVG mit g.animate({ transform: "s2.5,2.5," + bbox.cx + "," + bbox.cy }, 0); zu skalieren und dann wheelAnimation(bbox.cx, bbox.cy, 1500);Snap.svg Skala und animieren SVG

var i = 0; 
function wheelAnimation(cx, cy, speed){ 
    i++; 
    g.animate(
     { transform: "r360," + cx + ',' + cy}, // Basic rotation around a point. No frills. 
     speed, // Nice slow turning rays 
     function(){ 
      if(i == 5) 
       speed = 5000; 
      g.attr({ transform: 'rotate(0 ' + cx + ' ' + cy}); // Reset the position of the rays. 
      wheelAnimation(cx,cy, speed); // Repeat this animation so it appears infinite. 
     } 
    ); 
} 

animieren Aber meine SVG Skalierung nicht. Es dreht sich nur. Wenn ich Rotation entferne - SVG-Skalierung. Wie kombiniert man es, um die Rotation sofort zu skalieren und dann zu animieren?

Plunker example

Antwort

3

Ich habe Snap.svg nie benutzt, aber Sie könnten versuchen, diese:

var i = 0; 

function wheelAnimation(cx, cy, speed, scale){ 
    i++; 
    g.attr({ transform: "r0 " + cx + " " + cy + " s" + scale + "," + scale + "," + cx + "," + cy }); //Reset + Scale setup 
    g.animate({ 
     transform: "r360," + cx + "," + cy + " s" + scale + "," + scale + "," + cx + "," + cy }, // Basic rotation around a point. No frills. 
     speed, // Nice slow turning rays 
     function(){ 
     if(i == 5) 
      speed = 5000; 
     wheelAnimation(cx, cy, speed, scale); // Repeat this animation so it appears infinite. 
     } 
    ); 
} 

this helps you :)

See Plunkr

+0

Nice! Vielen Dank –

Verwandte Themen