如何重构snap.svg代码

时间:2015-11-29 22:22:10

标签: snap.svg

我确信这个代码可能更容易使用for循环。

var paper = Snap('#frame');
frame = paper.polygon(1 ,0 , 1, 1 , 0 ,1 , 0 ,0);
frame.attr({
  fill: 'yellow',
});

trFunc = function(){
    frame.animate({points:"0.9,0.175 , 1, 1 , 0 ,1 , 0 ,0"},700,mina.elastic);
}
brFunc = function(){
    frame.animate({points:"0.9,0.175 , 0.9, 0.825 , 0 ,1 , 0 ,0"},700,mina.elastic);
}

blFunc = function(){
  frame.animate({
    points:"0.9,0.175,0.9,0.825,0.1,0.825,0,0"
  },700,mina.elastic) 
}

tlFunc = function(){
  frame.animate({
    points:"0.9,0.175,0.9,0.825,0.1,0.825,0.1,0.175"
  },700,mina.elastic)
}

setTimeout(trFunc, 200);
setTimeout(brFunc, 400);
setTimeout(blFunc, 600);
setTimeout(tlFunc, 800);

0 个答案:

没有答案