Skip to content

OrangeTreeDev/SVG

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

SVG

学习SVG相关知识的总结笔记

描边动画

主要思路

使用path对象的getTotalLength方法获取path对象的长度,然后,设置stroke-dasharraystroke-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
);

效果截图

About

the coding libs about learing the SVG

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages