-
Notifications
You must be signed in to change notification settings - Fork 4
/
jquery.strokeanimation.min.js
21 lines (19 loc) · 1.87 KB
/
jquery.strokeanimation.min.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
/**
Stroke Animation Plugin - v1.0
@author Yu Ishihara
@github https://github.com/is8r/jquery-strokeanimation
@version 1.0
@howto
;(function(jQuery) {
$(function(){
$('.lines').strokeanimation({
interval: 5000,
loop: true,
//autoStart: false,
color: '#ffffff'
});
//$('.lines').data('strokeanimation').enter();
});
})(jQuery);
*/
!function(){var t="strokeanimation";$[t]=function(t,e){var s={pluginName:"strokeanimation",color:null,loop:!0,autoStart:!1,interval:3e3},n=this;n.settings={};var i=$(t),t=t;n.init=function(){n.settings=$.extend({},s,e),n.items=e.items,n.start()},n.start=function(){i.find("path").each(function(t,e){e.setAttribute("stroke-dashoffset","0"),n.settings.color&&(e.attributes.getNamedItem("stroke").nodeValue=n.settings.color)}),i.find("circle").each(function(t,e){e.setAttribute("stroke-dashoffset","0"),n.settings.color&&(e.attributes.getNamedItem("stroke").nodeValue=n.settings.color)}),n.settings.autoStart&&n.enter(),n.settings.loop&&setInterval(n.enter,n.settings.interval)},n.enter=function(){var e;t.style.display="block",i.find("path").each(function(t,s){s.style.transition=s.style.WebkitTransition="none",e=s.getTotalLength(),s.style.strokeDasharray=e+" "+e,s.style.strokeDashoffset=e,s.getBoundingClientRect(),s.style.transition=s.style.WebkitTransition="stroke-dashoffset 3s ease-in-out",s.style.strokeDashoffset="0"}),i.find("circle").each(function(t,s){s.style.transition=s.style.WebkitTransition="none",e=10*s.attributes.getNamedItem("r").nodeValue,s.style.strokeDasharray=e+" "+e,s.style.strokeDashoffset=e,s.getBoundingClientRect(),s.style.transition=s.style.WebkitTransition="stroke-dashoffset 3s ease-in-out",s.style.strokeDashoffset="0"})},n.init()},$.fn[t]=function(e){return e||(e={}),e.items=[],this.each(function(s){if(e.id=s,e.items.push($(this)),void 0==$(this).data(t)){var n=new $[t](this,e);$(this).data(t,n)}})}}(jQuery);