学习SVG相关知识的总结笔记
使用path对象的getTotalLength方法获取path对象的长度,然后,设置stroke-dasharray和stroke-dashoffset属性值等于path对象的长度。然后,利用动画特性,逐渐改变stroke-offseet属性值直到0。
var length = strokeRect.getTotalLength();
strokeRect.attr({'stroke-dasharray': length,'stroke-dashoffset':length});
Snap.animate(length, 0, function(val){
strokeRect.attr({'stroke-dashoffset':val});
}, 2000, mina.easeinout(), null
);