Sektor - draw and animate SVG sectors

For a current project I'm on, we needed both circular timer, and progress bar. Again, I wasn't able to find small library to do that. But I found awesome answer on Stack Overflow, decided SVG is way to go, and wrote Sektor.

Sektor is a plain JavaScript library that draws circle sector (or an arc). Once it is drawn, you can change it's angle and animate the change.

Sektor - draw and animate SVG circle

It works in every browser with SVG and requestAnimationFrane support (IE10+ and modern browsers). Check demo and docs.

I may use this for example how much better is to use requestAnimationFrame than setInterval. If you are bored, try it yourself, and you'll see that animating using requestAnimationFrame is way smoother.

React component is coming soon as well. Cheers!

Comments (3)

Bean Wong
13. Jun 2019, 05:00

Hello, is it possible to add easing for the animation part? Btw thank you so much you bring us "Sektor", it's great!

Stanko
13. Jun 2019, 08:21

Hey Bean, I'm really glad Sektor was useful for you.

To add easing you need to change this line: sektor.es6.js#L57

Just pass angle to a easing function and that's it. I would gladly accept a pull request if you have time to make one.

Cheers!

Bean Wong
14. Jun 2019, 03:06

Thanks for your reply Stanko, can i have a example to how to pass the "angle" to a easing function?