diff --git a/jquery.lazylinepainter-1.7.0.js b/jquery.lazylinepainter-1.7.0.js index 4a2a189..8008f19 100644 --- a/jquery.lazylinepainter-1.7.0.js +++ b/jquery.lazylinepainter-1.7.0.js @@ -5,7 +5,7 @@ * https://github.com/camoconnell/lazy-line-painter * http://www.camoconnell.com * - * Copyright 2013-2015 Cam O'Connell + * Copyright © 2013-2015 Cam O'Connell * All rights reserved. * * Licensed under the GNU license. diff --git a/jquery.lazylinepainter-1.7.0.min.js b/jquery.lazylinepainter-1.7.0.min.js index 8220153..0f441a8 100644 --- a/jquery.lazylinepainter-1.7.0.min.js +++ b/jquery.lazylinepainter-1.7.0.min.js @@ -5,10 +5,10 @@ * https://github.com/camoconnell/lazy-line-painter * http://www.camoconnell.com * - * Copyright 2015 Cam O'Connell + * Copyright © 2013-2015 Cam O'Connell * All rights reserved. * - * Licensed under the MIT license. + * Licensed under the GNU license. * */ @@ -47,21 +47,21 @@ */ -(function(k){var t={init:function(a){return this.each(function(){var c=k(this),b=c.data("lazyLinePainter");c.addClass("lazylinepainter");if(!b){var b=k.extend({width:null,height:null,strokeWidth:2,strokeDash:null,strokeColor:"#000",strokeOverColor:null,strokeCap:"round",strokeJoin:"round",strokeOpacity:1,onComplete:null,onUpdate:null,onStart:null,onStrokeStart:null,onStrokeComplete:null,delay:0,ease:null,overrideKey:null,drawSequential:!0,speedMultiplier:1,reverse:!1,paused:!1,progress:0},a),d=b.overrideKey? -b.overrideKey:c.attr("id").replace("#",""),e=b.svgData[d].dimensions.width,f=b.svgData[d].dimensions.height;b.paths=k.extend(!0,[],b.svgData[d].strokepath);null===b.width&&(b.width=e);null===b.height&&(b.height=f);d="0 0 "+e+" "+f;e=document.createElementNS("http://www.w3.org/2000/svg","svg");e.setAttributeNS(null,"viewBox",d);e.setAttribute("xmlns","http://www.w3.org/2000/svg");d=k(e);b.svg=d;c.append(b.svg);b.longestDuration=0;for(var g=b.playhead=0,e=d=b.delay*b.speedMultiplier,f=f=0;fb.longestDuration&&(b.longestDuration=g);q=g/e;m=b.reverse?m-g:b.playhead+d;n=m/e;h.duration=g;h.startTime=m;h.startProgress=n;h.durationProgress=q;h.progress=0;h.el=l;h.index=f;h.length=p;h.ease=h.ease||null;h.onStrokeStart=h.onStrokeStart||null;h.onStrokeComplete=h.onStrokeComplete||null;h.onStrokeStartDone=!1;h.onStrokeCompleteDone=!1;h.onStrokeUpdate=h.onStrokeUpdate||null;b.playhead+=g}b.totalDuration=b.drawSequential? -b.playhead:b.longestDuration;b.totalDuration+=d;c.data("lazyLinePainter",b);c.lazylinepainter("resize")}})},paint:function(){return this.each(function(){var a=k(this),c=a.data("lazyLinePainter");a.lazylinepainter("erase");c.rAF=requestAnimationFrame(function(a){r(a,c)});if(null!==c.onStart)c.onStart()})},pause:function(){return this.each(function(){var a=k(this).data("lazyLinePainter");a.paused||(a.paused=!0,cancelAnimationFrame(a.rAF))})},resume:function(){return this.each(function(){var a=k(this).data("lazyLinePainter"); -a.paused&&(requestAnimationFrame(function(c){z(c,a)}),a.paused=!1)})},erase:function(){return this.each(function(){var a=k(this).data("lazyLinePainter");a.startTime=null;a.elapsedTime=null;cancelAnimationFrame(a.rAF);a.onStrokeCompleteDone=!1;a.paused=!1;for(var c=0;cc.progress)c.rAF=requestAnimationFrame(function(a){r(a,c)});else if(null!==c.onComplete)c.onComplete()},v=function(a){for(var c=0;cb.startProgress&&a.progress=b.startProgress+b.durationProgress?d=1:a.progress<=b.startProgress&&(d=0):d=a.progress;b.progress= -x(1,0,d,b.ease);var d=b,e=d.progress*d.length;d.el.style.strokeDashoffset=a.reverse||d.reverse?-d.length+e:d.length-e;w(a,b);d=a;if(1===b.progress)d.onStrokeComplete&&d.drawSequential&&!b.onStrokeCompleteDone&&(d.onStrokeComplete(b),b.onStrokeComplete||(b.onStrokeCompleteDone=!0)),b.onStrokeComplete&&d.drawSequential&&!b.onStrokeCompleteDone&&(b.onStrokeComplete(b),b.onStrokeCompleteDone=!0);else if(1E-5=a?e=1:b<=c&&(e=0);return e},w=function(a,c){var b=Math.round(c.progress*(c.length-1)),b=c.positions[b];c.position={x:a.offset.left+b.x,y:a.offset.top+b.y}},y=function(a,c){return{d:c.path,stroke:c.strokeColor?c.strokeColor:a.strokeColor,"fill-opacity":0,"stroke-opacity":c.strokeOpacity? -c.strokeOpacity:a.strokeOpacity,"stroke-width":c.strokeWidth?c.strokeWidth:a.strokeWidth,"stroke-linecap":c.strokeCap?c.strokeCap:a.strokeCap,"stroke-linejoin":c.strokeJoin?c.strokeJoin:a.strokeJoin}},u=function(a,c){for(var b="",d=a.split(","),e=0,f=d.length-1;0<=f;f--)e+=Number(d[f]);d=Math.floor(c/e);for(f=d-1;0<=f;f--)b+=a+", ";return(b+(c-d*e)+", "+c).split(",").join("px,")+"px"};k.fn.lazylinepainter=function(a){if(t[a])return t[a].apply(this,Array.prototype.slice.call(arguments,1));if("object"!== -typeof a&&a)console.log("opps - issue finding method");else return t.init.apply(this,arguments)};var m={easeLinear:function(a,c,b,d){return b*a/d+c},easeInQuad:function(a,c,b,d){return b*(a/=d)*a+c},easeOutQuad:function(a,c,b,d){return-b*(a/=d)*(a-2)+c},easeInOutQuad:function(a,c,b,d){return 1>(a/=d/2)?b/2*a*a+c:-b/2*(--a*(a-2)-1)+c},easeInCubic:function(a,c,b,d){return b*(a/=d)*a*a+c},easeOutCubic:function(a,c,b,d){return b*((a=a/d-1)*a*a+1)+c},easeInOutCubic:function(a,c,b,d){return 1>(a/=d/2)? +(function(k){var u={init:function(a){return this.each(function(){var c=k(this),b=c.data("lazyLinePainter");c.addClass("lazylinepainter");if(!b){var b=k.extend({strokeWidth:2,strokeDash:null,strokeColor:"#000",strokeOverColor:null,strokeCap:"round",strokeJoin:"round",strokeOpacity:1,onComplete:null,onUpdate:null,onStart:null,onStrokeStart:null,onStrokeComplete:null,delay:0,ease:null,overrideKey:null,drawSequential:!0,speedMultiplier:1,reverse:!1,paused:!1,progress:0,_longestDuration:0,playhead:0}, +a),d=b.overrideKey?b.overrideKey:c.attr("id").replace("#","");b.width=b.svgData[d].dimensions.width;b.height=b.svgData[d].dimensions.height;b.paths=k.extend(!0,[],b.svgData[d].strokepath);var d="0 0 "+b.width+" "+b.height,e=document.createElementNS("http://www.w3.org/2000/svg","svg");e.setAttributeNS(null,"viewBox",d);e.setAttribute("xmlns","http://www.w3.org/2000/svg");d=k(e);b.svg=d;for(var d=b.delay*b.speedMultiplier,e=b.paths,g=d,h=0;hb._longestDuration&&(b._longestDuration=f.duration);l=f.duration/e;b.reverse?g-=f.duration:b.drawSequential?g=b.playhead+d:(g=f.delay+d,console.log(g));p=g/e;f.startTime=g;f.startProgress= +p;f.durationProgress=l;b.playhead+=f.duration}b.totalDuration=b.drawSequential?b.playhead:b._longestDuration;b.totalDuration+=d;c.append(b.svg);c.data("lazyLinePainter",b);c.lazylinepainter("resize")}})},paint:function(){return this.each(function(){var a=k(this),c=a.data("lazyLinePainter");a.lazylinepainter("erase");c.rAF=requestAnimationFrame(function(a){t(a,c)});if(null!==c.onStart)c.onStart()})},pause:function(){return this.each(function(){var a=k(this).data("lazyLinePainter");a.paused||(a.paused= +!0,cancelAnimationFrame(a.rAF))})},resume:function(){return this.each(function(){var a=k(this).data("lazyLinePainter");a.paused&&(requestAnimationFrame(function(c){A(c,a)}),a.paused=!1)})},erase:function(){return this.each(function(){var a=k(this).data("lazyLinePainter");a.startTime=null;a.elapsedTime=null;cancelAnimationFrame(a.rAF);a.onStrokeCompleteDone=!1;a.paused=!1;for(var c=0;cc.progress)c.rAF=requestAnimationFrame(function(a){t(a,c)});else if(null!==c.onComplete)c.onComplete()},w=function(a){for(var c=0;cb.startProgress&&a.progress=b.startProgress+ +b.durationProgress?d=1:a.progress<=b.startProgress&&(d=0);b.progress=y(1,0,d,b.ease);var d=b,e=d.progress*d.length;d.el.style.strokeDashoffset=a.reverse||d.reverse?-d.length+e:d.length-e;x(a,b);d=a;if(1===b.progress)d.onStrokeComplete&&!b.onStrokeCompleteDone&&(d.onStrokeComplete(b),b.onStrokeComplete||(b.onStrokeCompleteDone=!0)),b.onStrokeComplete&&!b.onStrokeCompleteDone&&(b.onStrokeComplete(b),b.onStrokeCompleteDone=!0);else if(1E-5=a?e=1:b<=c&&(e=0);return e},x=function(a,c){var b=Math.round(c.progress*(c.length-1)),b=c.positions[b];c.position={x:a.offset.left+b.x,y:a.offset.top+b.y}},z=function(a,c){return{d:c.path,stroke:c.strokeColor?c.strokeColor:a.strokeColor,"fill-opacity":0,"stroke-opacity":c.strokeOpacity? +c.strokeOpacity:a.strokeOpacity,"stroke-width":c.strokeWidth?c.strokeWidth:a.strokeWidth,"stroke-linecap":c.strokeCap?c.strokeCap:a.strokeCap,"stroke-linejoin":c.strokeJoin?c.strokeJoin:a.strokeJoin}},v=function(a,c){for(var b="",d=a.split(","),e=0,g=d.length-1;0<=g;g--)e+=Number(d[g]);d=Math.floor(c/e);for(g=d-1;0<=g;g--)b+=a+", ";return(b+(c-d*e)+", "+c).split(",").join("px,")+"px"};k.fn.lazylinepainter=function(a){if(u[a])return u[a].apply(this,Array.prototype.slice.call(arguments,1));if("object"!== +typeof a&&a)console.log("opps - issue finding method");else return u.init.apply(this,arguments)};var q={easeLinear:function(a,c,b,d){return b*a/d+c},easeInQuad:function(a,c,b,d){return b*(a/=d)*a+c},easeOutQuad:function(a,c,b,d){return-b*(a/=d)*(a-2)+c},easeInOutQuad:function(a,c,b,d){return 1>(a/=d/2)?b/2*a*a+c:-b/2*(--a*(a-2)-1)+c},easeInCubic:function(a,c,b,d){return b*(a/=d)*a*a+c},easeOutCubic:function(a,c,b,d){return b*((a=a/d-1)*a*a+1)+c},easeInOutCubic:function(a,c,b,d){return 1>(a/=d/2)? b/2*a*a*a+c:b/2*((a-=2)*a*a+2)+c},easeInQuart:function(a,c,b,d){return b*(a/=d)*a*a*a+c},easeOutQuart:function(a,c,b,d){return-b*((a=a/d-1)*a*a*a-1)+c},easeInOutQuart:function(a,c,b,d){return 1>(a/=d/2)?b/2*a*a*a*a+c:-b/2*((a-=2)*a*a*a-2)+c},easeInQuint:function(a,c,b,d){return b*(a/=d)*a*a*a*a+c},easeOutQuint:function(a,c,b,d){return b*((a=a/d-1)*a*a*a*a+1)+c},easeInOutQuint:function(a,c,b,d){return 1>(a/=d/2)?b/2*a*a*a*a*a+c:b/2*((a-=2)*a*a*a*a+2)+c},easeInSine:function(a,c,b,d){return-b*Math.cos(a/ d*(Math.PI/2))+b+c},easeOutSine:function(a,c,b,d){return b*Math.sin(a/d*(Math.PI/2))+c},easeInOutSine:function(a,c,b,d){return-b/2*(Math.cos(Math.PI*a/d)-1)+c},easeInExpo:function(a,c,b,d){return 0==a?c:b*Math.pow(2,10*(a/d-1))+c},easeOutExpo:function(a,c,b,d){return a==d?c+b:b*(-Math.pow(2,-10*a/d)+1)+c},easeInOutExpo:function(a,c,b,d){return 0==a?c:a==d?c+b:1>(a/=d/2)?b/2*Math.pow(2,10*(a-1))+c:b/2*(-Math.pow(2,-10*--a)+2)+c},easeInCirc:function(a,c,b,d){return-b*(Math.sqrt(1-(a/=d)*a)-1)+c},easeOutCirc:function(a, -c,b,d){return b*Math.sqrt(1-(a=a/d-1)*a)+c},easeInOutCirc:function(a,c,b,d){return 1>(a/=d/2)?-b/2*(Math.sqrt(1-a*a)-1)+c:b/2*(Math.sqrt(1-(a-=2)*a)+1)+c},easeInElastic:function(a,c,b,d){var e=1.70158,f=0,g=b;if(0==a)return c;if(1==(a/=d))return c+b;f||(f=.3*d);ga?-.5*g*Math.pow(2,10*--a)*Math.sin(2*(a*d-e)*Math.PI/f)+c:g*Math.pow(2,-10*--a)*Math.sin(2*(a*d-e)*Math.PI/f)*.5+b+c},easeInBack:function(a,c,b,d,e){void 0==e&&(e=1.70158);return b*(a/=d)*a*((e+1)*a-e)+c},easeOutBack:function(a, -c,b,d,e){void 0==e&&(e=1.70158);return b*((a=a/d-1)*a*((e+1)*a+e)+1)+c},easeInOutBack:function(a,c,b,d,e){void 0==e&&(e=1.70158);return 1>(a/=d/2)?b/2*a*a*(((e*=1.525)+1)*a-e)+c:b/2*((a-=2)*a*(((e*=1.525)+1)*a+e)+2)+c},easeInBounce:function(a,c,b,d){return b-m.easeOutBounce(d-a,0,b,d)+c},easeOutBounce:function(a,c,b,d){return(a/=d)<1/2.75?7.5625*b*a*a+c:a<2/2.75?b*(7.5625*(a-=1.5/2.75)*a+.75)+c:a<2.5/2.75?b*(7.5625*(a-=2.25/2.75)*a+.9375)+c:b*(7.5625*(a-=2.625/2.75)*a+.984375)+c},easeInOutBounce:function(a, -c,b,d){return a(a/=d/2)?-b/2*(Math.sqrt(1-a*a)-1)+c:b/2*(Math.sqrt(1-(a-=2)*a)+1)+c},easeInElastic:function(a,c,b,d){var e=1.70158,g=0,h=b;if(0==a)return c;if(1==(a/=d))return c+b;g||(g=.3*d);ha?-.5*h*Math.pow(2,10*--a)*Math.sin(2*(a*d-e)*Math.PI/g)+c:h*Math.pow(2,-10*--a)*Math.sin(2*(a*d-e)*Math.PI/g)*.5+b+c},easeInBack:function(a,c,b,d,e){void 0==e&&(e=1.70158);return b*(a/=d)*a*((e+1)*a-e)+c},easeOutBack:function(a, +c,b,d,e){void 0==e&&(e=1.70158);return b*((a=a/d-1)*a*((e+1)*a+e)+1)+c},easeInOutBack:function(a,c,b,d,e){void 0==e&&(e=1.70158);return 1>(a/=d/2)?b/2*a*a*(((e*=1.525)+1)*a-e)+c:b/2*((a-=2)*a*(((e*=1.525)+1)*a+e)+2)+c},easeInBounce:function(a,c,b,d){return b-q.easeOutBounce(d-a,0,b,d)+c},easeOutBounce:function(a,c,b,d){return(a/=d)<1/2.75?7.5625*b*a*a+c:a<2/2.75?b*(7.5625*(a-=1.5/2.75)*a+.75)+c:a<2.5/2.75?b*(7.5625*(a-=2.25/2.75)*a+.9375)+c:b*(7.5625*(a-=2.625/2.75)*a+.984375)+c},easeInOutBounce:function(a, +c,b,d){return a