We're gonna chain these tweens and start the animation. You can download this example here.
The first tween uses the translate: [580,0] notation and the second tween uses the translate: 0 notation. Keep in mind that the values are unitless and are relative to the viewBox attribute.
The first tween uses the CSS3 translate: 580 notation and the second tween uses the translate: [0,0] as svgTransform value. For the second example the values are unitless and are relative to the viewBox attribute.
For skews for SVGs we have a very simple notation: skewX: 25 or skewY: -25 as SVGs don't support the skew: [X,Y] function. Here's a quick demo:
The first tween skews the shape on X (horizontal) axis and the second tween skews the shape on Y (vertical) axis.
+The first tween skews the shape on both X and Y axis in a chain via regular CSS3 transforms and the second tween skews the shape on X and Y axis via the svgTransform tween property. The example also showcases the fact that chain transformations for SVGs via transform attribute works just as for the CSS3 transformations and you really have to check the example code here to learn how to master this technique.
For this particular example we've set transformOrigin option to "0px 0px" for the first shape (the default value for SVGs' transform-origin on most browsers) because we cannot set anything similar for the skews of the transform attribute for the second shape. Generally skews are hard to handle for SVGs because they are independent of any transform-origin. We can only compensate with translation, a very complicated story.
Our last transform example for SVGs is the scale. Unlike translations, for scale animation the plugin only accepts single value like scale: 1.5, for both X (horizontal) axis and Y (vertical) axis, to keep it simple and even if SVGs do support scale(X,Y). But because the scaling on SVGs depends very much on the shape's position, the script will always try to adjust the translation to make the animation look as we would expect. A quick demo:
Another transform example for SVGs is the scale. Unlike translations, for scale animation the plugin only accepts single value like scale: 1.5, for both X (horizontal) axis and Y (vertical) axis, to keep it simple and even if SVGs do support scale(X,Y). But because the scaling on SVGs depends very much on the shape's position, the script will always try to adjust the translation to make the animation look as we would expect. A quick demo:
The first tween scales the shape at scale: 1.5 and the second tween scales down the shape at scale: 0.5 value. If you inspect the elements, you will notice for both shapes translation is involved, and this is to keep transform-origin at an expected 50% 50% value, well, approximately.
The first tween scales the shape at scale: 1.5 via regular CSS3 transforms, and the second tween scales down the shape at scale: 0.5 value via svgTransform. If you inspect the elements, you will notice for the second shape translation is involved, and this is to keep transform-origin at an expected 50% 50% value. A similar case as with the skews.
Our last transform example for SVGs is the mixed transformation. Similar with scale animation the plugin will try to adjust the rotation transform-origin to make it look as you would expect it from regular HTML elements. Let's combine 3 functions at the same time and see what happens:
Both shapes are scaled at scale: 1.5, translated to translate: 250 and skewed at skewX: -15. If you inspect the elements, you will notice the second shape's translation is different from what we've set in the tween object, and this is to keep transform-origin at an expected 50% 50% value. This means that the plugin will also compensate rotation transform origin when skews are used, so that both CSS3 transform property and SVG transform attribute have an identical animation.
translate, rotate, skewX, skewY, scale.translate, scale, rotate, skewX and skewY. All this to make sure the animation looks like we would expect from regular HTML elements transformations. Maybe future versions will feature .matrix() transformations to handle all possible transform function combinations, but I'm going to need help with implementation and testing..getBBox() method, it's really useful to set custom transform-origin.overflow: hidden for <svg> so child elements are partially/completelly hidden while animating. You might want to set overflow: visible if that is the case or some browser specific tricks.overflow: hidden for <svg> so child elements are partialy/completely hidden while animating. You might want to set overflow: visible or some browser specific tricks if that is the case.viewBox="0 0 500 500" attribute for <svg> and no width and/or height attribute(s), means that you expect the SVG to be scalable and most Internet Explorer versions simply don't work. You might want to check this tutorial.transform animation featured in the core engine, the svgTransform feature does not stack properties for chains of tween objects created with the .to() method, you will have to provide all properties that you need in all chained tweens.svgTransform property DOES stack transform functions for chained tween objects created with the .to() method, you will have to provide only values for the functions that will change and the plugin will try to keep the unchanged values. However, there's a catch: you need to follow the properties that change and I highly recommend checking the example code for skews in the svg.js file..fromTo() method with all proper values.svgTransform feature does not support 3D transforms, because they are not supported in all browsers.A quick demo with the above:
Please note that strokeWidth is a very unique property that acts very different: when number is provided the rendered stroke will scale depending on viewBox and/or width and height, but if String is provided you can actually force the browser to scale the stroke as you like.
Now let's have a look at gradients, here we can animate the stopColor defined within the SVG's <linearGradient> element.
<linearGradient id="gradient1" x1="0%" y1="0%" x2="0%" y2="100%">
<stop offset="0%" style="stop-color: #ffd626; stop-opacity:1"></stop>
diff --git a/dist/kute-attr.min.js b/dist/kute-attr.min.js
index af75a25..e1e213c 100644
--- a/dist/kute-attr.min.js
+++ b/dist/kute-attr.min.js
@@ -1,2 +1,2 @@
// Attributes Plugin for KUTE.js | dnp_theme | MIT License
-!function(t){if("function"==typeof define&&define.amd)define(["./kute.js"],function(e){return t(e),e});else if("object"==typeof module&&"function"==typeof require){var e=require("./kute.js");module.exports=t(e)}else{if("undefined"==typeof window.KUTE)throw new Error("Attributes Plugin require KUTE.js.");t(e)}}(function(t){"use strict";var e=window.KUTE;e.gCA=function(t,e){return t.getAttribute(e)},e.prS.attr=function(t,r,n){var i={};for(var o in n)i[o.replace(/_+[a-z]+/,"")]=e.gCA(t,o.replace(/_+[a-z]+/,""));return i},"attr"in e.dom||(e.dom.attr=function(t,r,n){for(var i in t._vE[r])e.dom.attr.prototype[i](t,i,n)});var r=e.dom.attr.prototype;e.pp.attr=function(t,n){var i,o={};for(i in n)if(/%|px/.test(n[i])){var u=e.truD(n[i]).u,a=/%/.test(u)?"_percent":"_"+u;i+a in r||(r[i+a]=function(t,e,r){t._el.setAttribute(e.replace(a,""),t._vS.attr[e].v+(t._vE.attr[e].v-t._vS.attr[e].v)*r+t._vE.attr[e].u)}),o[i+a]=e.truD(n[i])}else i in r||(r[i]=function(t,e,r){t._el.setAttribute(e,t._vS.attr[e]+(t._vE.attr[e]-t._vS.attr[e])*r)}),o[i]=1*n[i];return o}});
\ No newline at end of file
+(function(c){if("function"===typeof define&&define.amd)define(["./kute.js"],function(a){c(a);return a});else if("object"==typeof module&&"function"==typeof require){var a=require("./kute.js");module.exports=c(a)}else if("undefined"!==typeof window.KUTE)c(a);else throw Error("Attributes Plugin require KUTE.js.");})(function(c){var a=window.KUTE,e=a.dom;c=a.pp;var k=a.Interpolate.unit,l=a.Interpolate.number;a.gCA=function(a,d){return a.getAttribute(d)};a.prS.attr=function(c,d,h){d={};for(var b in h)d[b.replace(/_+[a-z]+/,"")]=a.gCA(c,b.replace(/_+[a-z]+/,""));return d};"attr"in e||(e.attr=function(a,d,c,b,g){for(var f in b)e.attr.prototype[f](a,f,c[f],b[f],g)});var g=e.attr.prototype;c.attr=function(c,d){var h={},b;for(b in d)if(/%|px/.test(d[b])){var e=a.truD(d[b]).u,f=/%/.test(e)?"_percent":"_"+e;b+f in g||(g[b+f]=function(a,b,d,c,e){b=b.replace(f,"");a.setAttribute(b,k(d.v,c.v,c.u,e))});h[b+f]=a.truD(d[b])}else b in g||(g[b]=function(a,b,c,d,e){a.setAttribute(b,l(c,d,e))}),h[b]=1*d[b];return h}});
\ No newline at end of file
diff --git a/dist/kute-bezier.min.js b/dist/kute-bezier.min.js
index fd242f2..dfb052c 100644
--- a/dist/kute-bezier.min.js
+++ b/dist/kute-bezier.min.js
@@ -1,2 +1,2 @@
// Bezier Easing Functions for KUTE.js | dnp_theme | MIT License
-!function(n){if("function"==typeof define&&define.amd)define(["./kute.js"],function(e){return n(e),e});else if("object"==typeof module&&"function"==typeof require){var e=require("./kute.js");module.exports=n(e)}else{if("undefined"==typeof window.KUTE)throw new Error("Bezier Easing functions depend on KUTE.js. Read the docs for more info.");window.KUTE.Ease=window.KUTE.Ease||n(e)}}(function(n){"use strict";var e=e||{};e.Bezier=function(n,e,r,u){return t.pB(n,e,r,u)};var t=e.Bezier.prototype;return t.ni=4,t.nms=.001,t.sp=1e-7,t.smi=10,t.ksts=11,t.ksss=1/(t.ksts-1),t.f32as="Float32Array"in window,t.msv=t.f32as?new Float32Array(t.ksts):new Array(t.ksts),t.A=function(n,e){return 1-3*e+3*n},t.B=function(n,e){return 3*e-6*n},t.C=function(n){return 3*n},t.r={},t.pB=function(n,e,r,u){this._p=!1;var i=this;return t.r=function(s){return i._p||t.pc(n,r,e,u),n===e&&r===u?s:0===s?0:1===s?1:t.cB(t.gx(s,n,r),e,u)},t.r},t.cB=function(n,e,r){return((t.A(e,r)*n+t.B(e,r))*n+t.C(e))*n},t.gS=function(n,e,r){return 3*t.A(e,r)*n*n+2*t.B(e,r)*n+t.C(e)},t.bS=function(n,e,r,u,i){var s,o,c=0,f=t.sp,a=t.smi;do o=e+(r-e)/2,s=t.cB(o,u,i)-n,s>0?r=o:e=o;while(Math.abs(s)>f&&++ci;++i){var o=t.gS(e,r,u);if(0===o)return e;var c=t.cB(e,r,u)-n;e-=c/o}return e},t.csv=function(n,e){var r=0,u=t.ksts;for(r;u>r;++r)t.msv[r]=t.cB(r*t.ksss,n,e)},t.gx=function(n,e,r){for(var u=0,i=1,s=t.ksts-1;i!=s&&t.msv[i]<=n;++i)u+=t.ksss;--i;var o=(n-t.msv[i])/(t.msv[i+1]-t.msv[i]),c=u+o*t.ksss,f=t.gS(c,e,r),a=u+t.ksss;return f>=t.nms?t.nri(n,c,e,r):0===f?c:t.bS(n,u,a,e,r)},t.pc=function(n,e,r,u){this._p=!0,(n!=r||e!=u)&&t.csv(n,e)},e.easeIn=function(){return t.pB(.42,0,1,1)},e.easeOut=function(){return t.pB(0,0,.58,1)},e.easeInOut=function(){return t.pB(.5,.16,.49,.86)},e.easeInSine=function(){return t.pB(.47,0,.745,.715)},e.easeOutSine=function(){return t.pB(.39,.575,.565,1)},e.easeInOutSine=function(){return t.pB(.445,.05,.55,.95)},e.easeInQuad=function(){return t.pB(.55,.085,.68,.53)},e.easeOutQuad=function(){return t.pB(.25,.46,.45,.94)},e.easeInOutQuad=function(){return t.pB(.455,.03,.515,.955)},e.easeInCubic=function(){return t.pB(.55,.055,.675,.19)},e.easeOutCubic=function(){return t.pB(.215,.61,.355,1)},e.easeInOutCubic=function(){return t.pB(.645,.045,.355,1)},e.easeInQuart=function(){return t.pB(.895,.03,.685,.22)},e.easeOutQuart=function(){return t.pB(.165,.84,.44,1)},e.easeInOutQuart=function(){return t.pB(.77,0,.175,1)},e.easeInQuint=function(){return t.pB(.755,.05,.855,.06)},e.easeOutQuint=function(){return t.pB(.23,1,.32,1)},e.easeInOutQuint=function(){return t.pB(.86,0,.07,1)},e.easeInExpo=function(){return t.pB(.95,.05,.795,.035)},e.easeOutExpo=function(){return t.pB(.19,1,.22,1)},e.easeInOutExpo=function(){return t.pB(1,0,0,1)},e.easeInCirc=function(){return t.pB(.6,.04,.98,.335)},e.easeOutCirc=function(){return t.pB(.075,.82,.165,1)},e.easeInOutCirc=function(){return t.pB(.785,.135,.15,.86)},e.easeInBack=function(){return t.pB(.6,-.28,.735,.045)},e.easeOutBack=function(){return t.pB(.175,.885,.32,1.275)},e.easeInOutBack=function(){return t.pB(.68,-.55,.265,1.55)},e.slowMo=function(){return t.pB(0,.5,1,.5)},e.slowMo1=function(){return t.pB(0,.7,1,.3)},e.slowMo2=function(){return t.pB(0,.9,1,.1)},e});
\ No newline at end of file
+(function(k){if("function"===typeof define&&define.amd)define(["./kute.js"],function(a){k(a);return a});else if("object"==typeof module&&"function"==typeof require){var b=require("./kute.js");module.exports=k(b)}else if("undefined"!==typeof window.KUTE)window.KUTE.Ease=window.KUTE.Ease||k(b);else throw Error("Bezier Easing functions depend on KUTE.js. Read the docs for more info.");})(function(k){var b=b||{};b.Bezier=function(b,c,d,e){return a.pB(b,c,d,e)};var a=b.Bezier.prototype;a.ni=4;a.nms=.001;a.sp=1E-7;a.smi=10;a.ksts=11;a.ksss=1/(a.ksts-1);a.f32as="Float32Array"in window;a.msv=a.f32as?new Float32Array(a.ksts):Array(a.ksts);a.A=function(a,b){return 1-3*b+3*a};a.B=function(a,b){return 3*b-6*a};a.C=function(a){return 3*a};a.r={};a.pB=function(b,c,d,e){this._p=!1;var f=this;a.r=function(g){f._p||a.pc(b,d,c,e);return b===c&&d===e?g:0===g?0:1===g?1:a.cB(a.gx(g,b,d),c,e)};return a.r};a.cB=function(b,c,d){return((a.A(c,d)*b+a.B(c,d))*b+a.C(c))*b};a.gS=function(b,c,d){return 3*a.A(c,d)*b*b+2*a.B(c,d)*b+a.C(c)};a.bS=function(b,c,d,e,f){var g,h,k=0,l=a.sp,m=a.smi;do h=c+(d-c)/2,g=a.cB(h,e,f)-b,0l&&++k=a.nms?a.nri(b,f,c,d):0===g?f:a.bS(b,e,h,c,d)};a.pc=function(b,c,d,e){this._p=!0;b==d&&c==e||a.csv(b,c)};b.easeIn=function(){return a.pB(.42,0,1,1)};b.easeOut=function(){return a.pB(0,0,.58,1)};b.easeInOut=function(){return a.pB(.5,.16,.49,.86)};b.easeInSine=function(){return a.pB(.47,0,.745,.715)};b.easeOutSine=function(){return a.pB(.39,.575,.565,1)};b.easeInOutSine=function(){return a.pB(.445,.05,.55,.95)};b.easeInQuad=function(){return a.pB(.55,.085,.68,.53)};b.easeOutQuad=function(){return a.pB(.25,.46,.45,.94)};b.easeInOutQuad=function(){return a.pB(.455,.03,.515,.955)};b.easeInCubic=function(){return a.pB(.55,.055,.675,.19)};b.easeOutCubic=function(){return a.pB(.215,.61,.355,1)};b.easeInOutCubic=function(){return a.pB(.645,.045,.355,1)};b.easeInQuart=function(){return a.pB(.895,.03,.685,.22)};b.easeOutQuart=function(){return a.pB(.165,.84,.44,1)};b.easeInOutQuart=function(){return a.pB(.77,0,.175,1)};b.easeInQuint=function(){return a.pB(.755,.05,.855,.06)};b.easeOutQuint=function(){return a.pB(.23,1,.32,1)};b.easeInOutQuint=function(){return a.pB(.86,0,.07,1)};b.easeInExpo=function(){return a.pB(.95,.05,.795,.035)};b.easeOutExpo=function(){return a.pB(.19,1,.22,1)};b.easeInOutExpo=function(){return a.pB(1,0,0,1)};b.easeInCirc=function(){return a.pB(.6,.04,.98,.335)};b.easeOutCirc=function(){return a.pB(.075,.82,.165,1)};b.easeInOutCirc=function(){return a.pB(.785,.135,.15,.86)};b.easeInBack=function(){return a.pB(.6,-.28,.735,.045)};b.easeOutBack=function(){return a.pB(.175,.885,.32,1.275)};b.easeInOutBack=function(){return a.pB(.68,-.55,.265,1.55)};b.slowMo=function(){return a.pB(0,.5,1,.5)};b.slowMo1=function(){return a.pB(0,.7,1,.3)};b.slowMo2=function(){return a.pB(0,.9,1,.1)};return b});
\ No newline at end of file
diff --git a/dist/kute-css.min.js b/dist/kute-css.min.js
index a1b826a..2f40381 100644
--- a/dist/kute-css.min.js
+++ b/dist/kute-css.min.js
@@ -1,2 +1,2 @@
// CSS Plugin for KUTE.js | dnp_theme | MIT License
-!function(t){if("function"==typeof define&&define.amd)define(["./kute.js"],function(r){return t(r),r});else if("object"==typeof module&&"function"==typeof require){var r=require("./kute.js");module.exports=t(r)}else{if("undefined"==typeof window.KUTE)throw new Error("CSS Plugin require KUTE.js.");t(r)}}(function(t){for(var r,e=window.KUTE,o=e.property("borderRadius"),i=e.property("borderTopLeftRadius"),n=e.property("borderTopRightRadius"),u=e.property("borderBottomLeftRadius"),d=e.property("borderBottomRightRadius"),a=["borderColor","borderTopColor","borderRightColor","borderBottomColor","borderLeftColor","outlineColor"],v=["borderRadius","borderTopLeftRadius","borderTopRightRadius","borderBottomLeftRadius","borderBottomRightRadius"],l=["right","bottom","minWidth","minHeight","maxWidth","maxHeight","padding","margin","paddingTop","paddingBottom","paddingLeft","paddingRight","marginTop","marginBottom","marginLeft","marginRight","borderWidth","borderTopWidth","borderRightWidth","borderBottomWidth","borderLeftWidth","outlineWidth"],p=["fontSize","lineHeight","letterSpacing","wordSpacing"],f=["clip"],g=["backgroundPosition"],_=v.concat(l,p),s=a.concat(f,v,l,p,g),c=s.length,b=b||{},m=0;c>m;m++)r=s[m],-1!==a.indexOf(r)?b[r]="rgba(0,0,0,0)":-1!==_.indexOf(r)?b[r]=0:-1!==g.indexOf(r)?b[r]=[50,50]:"clip"===r&&(b[r]=[0,0,0,0]);for(var m=0,S=a.length;S>m;m++)r=a[m],e.pp[r]=function(t,r){return t in e.dom||(e.dom[t]=function(t,r,o){var i={};for(var n in t._vE[r].value)"a"!==n?i[n]=parseInt(t._vS[r].value[n]+(t._vE[r].value[n]-t._vS[r].value[n])*o)||0:i[n]=t._vS[r].value[n]&&t._vE[r].value[n]?parseFloat(t._vS[r].value[n]+(t._vE[r].value[n]-t._vS[r].value[n])*o):null;t._hex?t._el.style[r]=e.rth(i.r,i.g,i.b):t._el.style[r]=!i.a||_isIE8?"rgb("+i.r+","+i.g+","+i.b+")":"rgba("+i.r+","+i.g+","+i.b+","+i.a+")"}),e.pp.cls(t,r)},e.prS[r]=function(t,r,o){return e.gCS(t,r)||b[r]};for(var m=0,S=_.length;S>m;m++)r=_[m],e.pp[r]=function(t,r){return t in e.dom||(e.dom[t]=function(t,r,e){t._el.style[r]=t._vS[r].value+(t._vE[r].value-t._vS[r].value)*e+t._vE[r].unit}),e.pp.box(t,r)},e.prS[r]=function(t,r,o){return e.gCS(t,r)||b[r]};for(var m=0,S=v.length;S>m;m++)r=v[m],e.pp[r]=function(t,r){return t in e.dom||("borderRadius"===t?e.dom[t]=function(t,r,e){t._el.style[o]=t._vS[r].value+(t._vE[r].value-t._vS[r].value)*e+t._vE[r].unit}:"borderTopLeftRadius"===t?e.dom[t]=function(t,r,e){t._el.style[i]=t._vS[r].value+(t._vE[r].value-t._vS[r].value)*e+t._vE[r].unit}:"borderTopRightRadius"===t?e.dom[t]=function(t,r,e){t._el.style[n]=t._vS[r].value+(t._vE[r].value-t._vS[r].value)*e+t._vE[r].unit}:"borderBottomLeftRadius"===t?e.dom[t]=function(t,r,e){t._el.style[u]=t._vS[r].value+(t._vE[r].value-t._vS[r].value)*e+t._vE[r].unit}:"borderBottomRightRadius"===t&&(e.dom[t]=function(t,r,e){t._el.style[d]=t._vS[r].value+(t._vE[r].value-t._vS[r].value)*e+t._vE[r].unit})),e.pp.box(t,r)},e.prS[r]=function(t,r,o){return e.gCS(t,r)||b[r]};return e.pp.clip=function(t,r){if(t in e.dom||(e.dom[t]=function(t,r,e){var o=0,i=[];for(o;4>o;o++){var n=t._vS[r][o].v,u=t._vE[r][o].v,d=t._vE[r][o].u||"px";i[o]=n+(u-n)*e+d}t._el.style[r]="rect("+i+")"}),r instanceof Array)return[e.truD(r[0]),e.truD(r[1]),e.truD(r[2]),e.truD(r[3])];var o=r.replace(/rect|\(|\)/g,"");return o=/\,/g.test(o)?o.split(/\,/g):o.split(/\s/g),[e.truD(o[0]),e.truD(o[1]),e.truD(o[2]),e.truD(o[3])]},e.prS.clip=function(t,r,o){var i=e.gCS(t,r),n=e.gCS(t,"width"),u=e.gCS(t,"height");return/rect/.test(i)?i:[0,n,u,0]},e.pp.backgroundPosition=function(t,r){if(t in e.dom||(e.dom[t]=function(t,r,e){var o=t._vS[r].x.v,i=t._vE[r].x.v,n=t._vS[r].y.v,u=t._vE[r].y.v,d=o+(i-o)*e,a="%",v=n+(u-n)*e,l="%";t._el.style[r]=d+a+" "+v+l}),r instanceof Array)return{x:e.truD(r[0])||{v:50,u:"%"},y:e.truD(r[1])||{v:50,u:"%"}};var o,i,n=r.replace(/top|left/g,0).replace(/right|bottom/g,100).replace(/center|middle/g,50);return n=/\,/g.test(n)?n.split(/\,/g):n.split(/\s/g),n=2===n.length?n:[n[0],50],o=e.truD(n[0]),i=e.truD(n[1]),{x:o,y:i}},e.prS.backgroundPosition=function(t,r,o){return e.gCS(t,r)||b[r]},this});
\ No newline at end of file
+(function(h){if("function"===typeof define&&define.amd)define(["./kute.js"],function(a){h(a);return a});else if("object"==typeof module&&"function"==typeof require){var a=require("./kute.js");module.exports=h(a)}else if("undefined"!=typeof window.KUTE)h(a);else throw Error("CSS Plugin require KUTE.js.");})(function(h){var a=window.KUTE,c,g=a.dom,m=a.pp,t=a.property("borderRadius"),u=a.property("borderTopLeftRadius"),v=a.property("borderTopRightRadius"),w=a.property("borderBottomLeftRadius"),x=a.property("borderBottomRightRadius");h="borderColor borderTopColor borderRightColor borderBottomColor borderLeftColor outlineColor".split(" ");var p=["borderRadius","borderTopLeftRadius","borderTopRightRadius","borderBottomLeftRadius","borderBottomRightRadius"];c="right bottom minWidth minHeight maxWidth maxHeight padding margin paddingTop paddingBottom paddingLeft paddingRight marginTop marginBottom marginLeft marginRight borderWidth borderTopWidth borderRightWidth borderBottomWidth borderLeftWidth outlineWidth".split(" ");for(var b=["fontSize","lineHeight","letterSpacing","wordSpacing"],n=["backgroundPosition"],q=p.concat(c,b),r=h.concat(["clip"],p,c,b,n),y=r.length,k=a.Interpolate.unit,z=a.Interpolate.color,l=l||{},b=0;be;e++)g[e]=k(b[e].v,d[e].v,d[e].u||"px",f);a.style[c]="rect("+g+")"});if(d instanceof Array)return[a.truD(d[0]),a.truD(d[1]),a.truD(d[2]),a.truD(d[3])];var b=d.replace(/rect|\(|\)/g,""),b=/\,/g.test(b)?b.split(/\,/g):b.split(/\s/g);return[a.truD(b[0]),a.truD(b[1]),a.truD(b[2]),a.truD(b[3])]};a.prS.clip=function(c,b,e){b=a.gCS(c,b);e=a.gCS(c,"width");c=a.gCS(c,"height");return/rect/.test(b)?b:[0,e,c,0]};m.backgroundPosition=function(c,b){c in g||(g[c]=function(a,c,b,d,e){a.style[c]=k(b.x.v,d.x.v,"%",e)+" "+k(b.y.v,d.y.v,"%",e)});if(b instanceof Array)return{x:a.truD(b[0])||{v:50,u:"%"},y:a.truD(b[1])||{v:50,u:"%"}};var e=b.replace(/top|left/g,0).replace(/right|bottom/g,100).replace(/center|middle/g,50),h,e=/\,/g.test(e)?e.split(/\,/g):e.split(/\s/g),e=2===e.length?e:[e[0],50];h=a.truD(e[0]);e=a.truD(e[1]);return{x:h,y:e}};a.prS.backgroundPosition=function(c,b,e){return a.gCS(c,b)||l[b]};return this});
\ No newline at end of file
diff --git a/dist/kute-svg.min.js b/dist/kute-svg.min.js
index ab51269..156fa14 100644
--- a/dist/kute-svg.min.js
+++ b/dist/kute-svg.min.js
@@ -1,2 +1,2 @@
// SVG Plugin for KUTE.js | dnp_theme | MIT License
-!function(a){if("function"==typeof define&&define.amd)define(["./kute.js"],function(b){return a(b),b});else if("object"==typeof module&&"function"==typeof require){var b=require("./kute.js");module.exports=a(b)}else{if("undefined"==typeof window.KUTE)throw new Error("SVG Plugin require KUTE.js.");window.KUTE.svg=window.KUTE.svg||a(b)}}(function(a){"use strict";var d,b=window.KUTE,c=c||{},e=document.querySelector("path")||document.querySelector("svg"),f=e&&e.ownerSVGElement&&e.ownerSVGElement.namespaceURI||"http://www.w3.org/2000/svg",g=["strokeWidth","strokeOpacity","fillOpacity","stopOpacity"],h=["fill","stroke","stopColor"],i=/(m[^(h|v|l)]*|[vhl][^(v|h|l|z)]*)/gim;if(!e||e.ownerSVGElement){c.gPt=function(a){var b={},d="object"==typeof a?a:/^\.|^\#/.test(a)?document.querySelector(a):null;if(d&&/path|glyph/.test(d.tagName))b.e=c.fPt(d),b.o=d.getAttribute("d");else if(!d&&/[a-z][^a-z]*/gi.test(a)){var e=c.cP(a.trim());b.e=e,b.o=a}return b},c.pCr=function(a){this._mpr=a.morphPrecision||25,this._midx=a.morphIndex,this._smi=a.showMorphInfo,this._rv1=a.reverseFirstPath,this._rv2=a.reverseSecondPath;var e,b=c.gOp(a._vS.path.o),d=c.gOp(a._vE.path.o);this._isp=!/[CSQTA]/i.test(b)&&!/[CSQTA]/i.test(d),e=c._pCr(b,d,a._el.parentNode),a._vS.path.d=e[0],a._vE.path.d=e[1]},c._pCr=function(a,b,d){var e,f,g,h,i,j,k,l,o,q,r,s,n=[];if(this._sp=!1,this._isp)if(a=c.pTA(a),b=c.pTA(b),a.length!==b.length){i=Math.max(a.length,b.length),i===b.length?(j=a,k=b):(j=b,k=a),o=j.length,l=c.cP("M"+j.join("L")+"z"),q=l.getTotalLength()/i;for(var t=0;t2?b[0].trim()+"z":a.trim()},c.cP=function(a){var b=document.createElementNS(f,"path"),c="object"==typeof a?a.getAttribute("d"):a;return b.setAttribute("d",c),b},c.fPt=function(a){if("glyph"===a.tagName){var b=c.cP(a);return a.parentNode.appendChild(b),b}return a},c.clone=function(a){var b;if(a instanceof Array){b=[];for(var d=0,e=a.length;d1){var d=function(a){var b=a.split(",");if(2==b.length&&!isNaN(b[0])&&!isNaN(b[1]))return[parseFloat(b[0]),parseFloat(b[1])]},e=function(a,b){return void 0!=a&&void 0!=b?Math.sqrt(Math.pow(b[0]-a[0],2)+Math.pow(b[1]-a[1],2)):0};if(b.length>2)for(var f=0;fk;k++){g=e[k];d=g.length;h=0===k?{f:"DeepPink",o:"HotPink"}:{f:"Lime",o:"LimeGreen"};for(var n=0;nc+d?"0px, "+b+"px":c+d+"px, "+b+"px"});return d.gDr(c,b)};l.prS.draw=function(a,b,c){return d.gDr(a)};d.gL=function(a){if(/rect/.test(a.tagName))return d.gRL(a);if(/circle/.test(a.tagName))return d.gCL(a);if(/ellipse/.test(a.tagName))return d.gEL(a);if(/polygon|polyline/.test(a.tagName))return d.gPL(a);if(/line/.test(a.tagName))return d.gLL(a)};d.gRL=function(a){var b=a.getAttribute("width");a=a.getAttribute("height");return 2*b+2*a};d.gPL=function(a){a=a.getAttribute("points").split(" ");var b=0;if(1,./?=-").split(""),i=String("0123456789").split(""),o=e.concat(n,i),u=o.concat(r),s=Math.random,a=Math.floor,p=Math.min;return t.prS.text=t.prS.number=function(t,e,n){return t.innerHTML},t.pp.text=function(f,l,h){return"text"in t.dom||(t.dom.text=function(t,f,l){var h=h||"alpha"===t.textChars?e:"upper"===t.textChars?n:"numeric"===t.textChars?i:"alphanumeric"===t.textChars?o:"symbols"===t.textChars?r:"all"===t.textChars?u:t.textChars?t.textChars.split(""):e,c=h.length,m=t._vE[f],d=h[a(s()*c)],x="",g=m.substring(0);x=g.substring(0,a(p(l*g.length,g.length))),t._el.innerHTML=1>l?x+d:x}),l},t.pp.number=function(e,n,r){return"number"in t.dom||(t.dom.number=function(t,e,n){t._el.innerHTML=parseInt(t._vS[e]+(t._vE[e]-t._vS[e])*n)}),parseInt(n)||0},this});
\ No newline at end of file
+(function(b){if("function"===typeof define&&define.amd)define(["./kute.js"],function(a){b(a);return a});else if("object"==typeof module&&"function"==typeof require){var a=require("./kute.js");module.exports=b(a)}else if("undefined"!==typeof window.KUTE)b();else throw Error("Text-Plugin requires KUTE.js.");})(function(){var b=window.KUTE,a=b.dom,e=b.pp,t=b.Interpolate.number,d="abcdefghijklmnopqrstuvwxyz".split(""),l="ABCDEFGHIJKLMNOPQRSTUVWXYZ".split(""),m="~!@#$%^&*()_+{}[];'<>,./?=-".split(""),n="0123456789".split(""),p=d.concat(l,n);p.concat(m);var u=Math.random,k=Math.floor,q=Math.min;b.prS.text=b.prS.number=function(b,a,d){return b.innerHTML};e.text=function(b,v,e){"text"in a||(a.text=function(b,a,h,r,f,c){var g=g||"alpha"===c.textChars?d:"upper"===c.textChars?l:"numeric"===c.textChars?n:"alphanumeric"===c.textChars?p:"symbols"===c.textChars?m:c.textChars?c.textChars.split(""):d;a=g.length;g=g[k(u()*a)];c=h.substring(0);a=r.substring(0);h=""!==h?c.substring(c.length,k(q(f*c.length,c.length))):"";a=a.substring(0,k(q(f*a.length,a.length)));b.innerHTML=1>f?a+g+h:r});return v};e.number=function(b,d,e){"number"in a||(a.number=function(a,b,d,e,f){a.innerHTML=parseInt(t(d,e,f))});return parseInt(d)||0};return this});
\ No newline at end of file
diff --git a/dist/kute.min.js b/dist/kute.min.js
index 42ca041..586f9b8 100644
--- a/dist/kute.min.js
+++ b/dist/kute.min.js
@@ -1,2 +1,33 @@
// KUTE.js | dnp_theme | MIT-License
-!function(a){"function"==typeof define&&define.amd?define([],a):"object"==typeof exports?module.exports=a():window.KUTE=window.KUTE||a()}(function(){"use strict";var c,a=a||{},b=[],d=Math.min;a.getPrefix=function(){var a=document.createElement("div"),b=0,c=["Moz","moz","Webkit","webkit","O","o","Ms","ms"],d=c.length,e=["MozTransform","mozTransform","WebkitTransform","webkitTransform","OTransform","oTransform","MsTransform","msTransform"];for(b;b0)return b._r<9999&&b._r--,b._y&&(b.reversed=!b.reversed,b.rvs()),b._sT=b._y&&!b.reversed?c+b._rD:c,!0;b._cC&&b._cC.call(),b.scrollOut();var g=0,h=b._cT.length;for(g;g2?2:f,e=0;e0&&(c._r=c.repeat),c._y&&c.reversed===!0&&(c.rvs(),c.reversed=!1),c.playing=!1},64)},a.TweensTO=function(b,c,d){this.tweens=[];var e,f=b.length,g=[];for(e=0;e0?d.delay+(d.offset||0):d.delay,this.tweens.push(a.to(b[e],c,g[e]))},a.TweensFT=function(b,c,d,e){this.tweens=[];var f,g=b.length,h=[];for(f=0;f0?e.delay+(e.offset||0):e.delay,this.tweens.push(a.fromTo(b[f],c,d,h[f]))};var J=a.TweensTO.prototype=a.TweensFT.prototype;return J.start=function(a){a=a||window.performance.now();var b,c=this.tweens.length;for(b=0;ba._r&&a._r--,a._y&&(a.reversed=!a.reversed,a.rvs()),a._sT=a._y&&
+!a.reversed?b+a._rD:b;else{a._cC&&a._cC.call();a.scrollOut();d=0;c=a._cT.length;for(d;dp;p++){var y=q[p];/3d/.test(l)?U["translate"+y]=C.tf("translate"+y,w[l][p]):
+U["translate"+y]="translate"+y in w?C.tf("translate"+y,w["translate"+y]):{value:0,unit:"px"}}h.translate=U}else if(/^rotate(?:[XYZ])$|^skew(?:[XY])$/.test(l)){var q=/rotate/.test(l)?"rotate":"skew",p=["X","Y","Z"],y=0,z="rotate"===q?m:f;for(y;3>y;y++){var k=p[y];void 0!==w[q+k]&&"skewZ"!==l&&(z[q+k]=C.tf(q+k,w[q+k]))}h[q]=z}else/(rotate|translate|scale)$/.test(l)&&(h[l]=C.tf(l,w[l]));t[c].transform=h}else"transform"!==l&&(-1!==R.indexOf(l)?t[c][l]=C.box(l,w[l]):-1!==ea.indexOf(l)||-1!==Q.indexOf(l)?
+t[c][l]=C.unl(l,w[l]):-1!==P.indexOf(l)?t[c][l]=C.cls(l,w[l]):l in u.pp&&(t[c][l]=u.pp[l](l,w[l],d)))}return t},C={box:function(a,b){a in x||(x[a]=function(a,b,g,t,w){a.style[b]=ha(g.value,t.value,t.unit,w)});return{value:h(b).v,unit:h(b).u}},tf:function(a,b){"transform"in x||(x.transform=function(a,b,c,d,f,m){b="";var h,u=u||m.perspective&&0!==parseInt(m.perspective)?"perspective("+parseInt(m.perspective)+"px) ":!1;for(h in d){var q=c[h];m=d[h];if("translate"===h){var p={},y;for(y in m){var z=q[y].value||
+0,k=m[y].value||0,n=m[y].unit||"px";p[y]=z===k?k+n:z+(k-z)*f+n}m=m.x?"translate("+p.x+","+p.y+")":"translate3d("+p.translateX+","+p.translateY+","+p.translateZ+")";b=""===b?m:m+" "+b}else if("rotate"===h){var p={},r;for(r in m)q[r]&&(k=q[r].value,z=m[r].unit||"deg",k+=(m[r].value-k)*f,p[r]="z"===r?"rotate("+k+z+")":r+"("+k+z+") ");m=m.z?p.z:(p.rotateX||"")+(p.rotateY||"")+(p.rotateZ||"");b=""===b?m:b+" "+m}else if("skew"===h){var p={},v;for(v in m)q[v]&&(z=q[v].value,p[v]=v+"("+(z+(m[v].value-z)*
+f)+(m[v].unit||"deg")+") ");m=(p.skewX||"")+(p.skewY||"");b=""===b?m:b+" "+m}else"scale"===h&&(q=q.value,m=h+"("+(q+(m.value-q)*f)+")",b=""===b?m:b+" "+m)}a.style[oa]=u?u+b:b});if("translate3d"===a){var d=b.split(",");return{translateX:{value:h(d[0]).v,unit:h(d[0]).u},translateY:{value:h(d[1]).v,unit:h(d[1]).u},translateZ:{value:h(d[2]).v,unit:h(d[2]).u}}}if(/^translate(?:[XYZ])$/.test(a))return{value:h(b).v,unit:h(b).u||"px"};if(/^rotate(?:[XYZ])$|skew(?:[XY])$/.test(a))return{value:h(b,!0).v,unit:h(b,
+!0).u||"deg"};if("translate"===a){var d="string"===typeof b?b.split(","):b,c={};d instanceof Array?(c.x={value:h(d[0]).v,unit:h(d[0]).u},c.y={value:h(d[1]).v,unit:h(d[1]).u}):(c.x={value:h(d).v,unit:h(d).u},c.y={value:0,unit:"px"});return c}if("rotate"===a)return d={},d.z={value:h(b,!0).v,unit:h(b,!0).u||"deg"},d;if("scale"===a)return{value:parseFloat(b)}},unl:function(a,b){!/scroll/.test(a)||a in x?"opacity"===a&&(a in x||(x[a]=da?function(a,b,g,t,w){a.style.filter="alpha(opacity="+100*I(g,t,w)+
+")"}:function(a,b,g,t,w){a.style.opacity=I(g,t,w)})):x[a]=function(a,b,g,t,w){var l=l||void 0===a||null===a?ca:a;l.scrollTop=I(g,t,w)};return parseFloat(b)},cls:function(a,b){a in x||(x[a]=function(a,b,g,t,w,l){a.style[b]=ia(g,t,w,l.keepHex)});return M(b)}},f={},sa=Math.PI,D=2*Math.PI,la=Math.PI/2,n=.1;f.linear=function(a){return a};f.easingSinusoidalIn=function(a){return-Math.cos(a*la)+1};f.easingSinusoidalOut=function(a){return Math.sin(a*la)};f.easingSinusoidalInOut=function(a){return-.5*(Math.cos(sa*
+a)-1)};f.easingQuadraticIn=function(a){return a*a};f.easingQuadraticOut=function(a){return a*(2-a)};f.easingQuadraticInOut=function(a){return.5>a?2*a*a:-1+(4-2*a)*a};f.easingCubicIn=function(a){return a*a*a};f.easingCubicOut=function(a){return--a*a*a+1};f.easingCubicInOut=function(a){return.5>a?4*a*a*a:(a-1)*(2*a-2)*(2*a-2)+1};f.easingQuarticIn=function(a){return a*a*a*a};f.easingQuarticOut=function(a){return 1- --a*a*a*a};f.easingQuarticInOut=function(a){return.5>a?8*a*a*a*a:1-8*--a*a*a*a};f.easingQuinticIn=
+function(a){return a*a*a*a*a};f.easingQuinticOut=function(a){return 1+--a*a*a*a*a};f.easingQuinticInOut=function(a){return.5>a?16*a*a*a*a*a:1+16*--a*a*a*a*a};f.easingCircularIn=function(a){return-(Math.sqrt(1-a*a)-1)};f.easingCircularOut=function(a){return Math.sqrt(1- --a*a)};f.easingCircularInOut=function(a){return 1>(a*=2)?-.5*(Math.sqrt(1-a*a)-1):.5*(Math.sqrt(1-(a-=2)*a)+1)};f.easingExponentialIn=function(a){return Math.pow(2,10*(a-1))-.001};f.easingExponentialOut=function(a){return 1-Math.pow(2,
+-10*a)};f.easingExponentialInOut=function(a){return 1>(a*=2)?.5*Math.pow(2,10*(a-1)):.5*(2-Math.pow(2,-10*(a-1)))};f.easingBackIn=function(a){return a*a*(2.70158*a-1.70158)};f.easingBackOut=function(a){return--a*a*(2.70158*a+1.70158)+1};f.easingBackInOut=function(a){return 1>(a*=2)?.5*a*a*(3.5949095*a-2.5949095):.5*((a-=2)*a*(3.5949095*a+2.5949095)+2)};f.easingElasticIn=function(a){var b;if(0===a)return 0;if(1===a)return 1;!n||1>n?(n=1,b=.1):b=.4*Math.asin(1/n)/D;return-(n*Math.pow(2,10*--a)*Math.sin((a-
+b)*D/.4))};f.easingElasticOut=function(a){var b;if(0===a)return 0;if(1===a)return 1;!n||1>n?(n=1,b=.1):b=.4*Math.asin(1/n)/D;return n*Math.pow(2,-10*a)*Math.sin((a-b)*D/.4)+1};f.easingElasticInOut=function(a){var b;if(0===a)return 0;if(1===a)return 1;!n||1>n?(n=1,b=.1):b=.4*Math.asin(1/n)/D;return 1>(a*=2)?-.5*n*Math.pow(2,10*--a)*Math.sin((a-b)*D/.4):n*Math.pow(2,-10*--a)*Math.sin((a-b)*D/.4)*.5+1};f.easingBounceIn=function(a){return 1-f.easingBounceOut(1-a)};f.easingBounceOut=function(a){return a<
+1/2.75?7.5625*a*a:a<2/2.75?7.5625*(a-=1.5/2.75)*a+.75:a<2.5/2.75?7.5625*(a-=2.25/2.75)*a+.9375:7.5625*(a-=2.625/2.75)*a+.984375};f.easingBounceInOut=function(a){return.5>a?.5*f.easingBounceIn(2*a):.5*f.easingBounceOut(2*a-1)+.5};var H=function(a,b,d,c){this._el=a;this._vSR={};this._vS=b;this._vE=d;this._y=c.yoyo||!1;this.paused=this.reversed=this.playing=!1;this._pST=this._sT=null;this._hex=c.keepHex||!1;this._rpr=c.rpr||!1;this._dr=c.duration||700;this._r=c.repeat||0;this._rD=c.repeatDelay||0;this._dl=
+c.delay||0;this._to=c.transformOrigin;this._pp=c.perspective&&0!==parseInt(c.perspective)?"perspective("+parseInt(c.perspective)+"px) ":!1;this._ppo=c.perspectiveOrigin;this._ppp=c.parentPerspective;this._pppo=c.parentPerspectiveOrigin;this._e=c&&c.easing&&"function"===typeof O(c.easing)?O(c.easing):f.linear;this._cT=[];this._sCF=!1;this._sC=c.start||null;this._uC=c.update||null;this._cC=c.complete||null;this._pC=c.pause||null;this._rC=c.play||null;this._stC=c.stop||null;this.repeat=this._r;this._ops=
+{};for(var g in c)g in this||/delay|duration|repeat|origin|start|stop|update|complete|pause|play|yoyo|easing/i.test(g)||(this._ops[g]=c[g]);this.pause=function(){!this.paused&&this.playing&&(ka(this),this.paused=!0,this._pST=window.performance.now(),null!==this._pC&&this._pC.call());return this};this.stop=function(){!this.paused&&this.playing&&(ka(this),this.paused=this.playing=!1,this.scrollOut(),null!==this._stC&&this._stC.call(),this.stopChainedTweens(),this.close());return this};this.rvs=function(){if(this._y)for(var a in this._vE){var b=
+this._vSR[a];this._vSR[a]=this._vE[a];this._vE[a]=b;this._vS[a]=this._vSR[a]}};this.chain=function(){this._cT=arguments;return this};this.stopChainedTweens=function(){var a=0,b=this._cT.length;for(a;ax;x++)for(h=0;3>h;h++)q=g[x]+f[h],-1!==G.indexOf(q)&&q in c&&(a[q]=
+d[q]||v[q])}else-1===Q.indexOf(k)?"opacity"===k&&da?(h=N(b,"filter"),a.opacity="number"===typeof h?h:v.opacity):-1!==S.indexOf(k)?a[k]=N(b,k)||x[k]:a[k]=k in u.prS?u.prS[k](b,k,c[k]):0:a[k]=null===b||void 0===b?window.pageYOffset||ca.scrollTop:b.scrollTop;for(k in d)-1===G.indexOf(k)||k in c||(a[k]=d[k]||v[k]);return a};this.close=function(){var a=this;setTimeout(function(){B.indexOf(a)===B.length-1&&(E&&qa(E),E=null);0 2) {
- return a[0].trim() + 'z';
- } else { return p.trim(); }
+ return p.split(/z/i).shift() + 'z';
}
S.cP = function (p){ // createPath
@@ -216,7 +223,7 @@
np[i] = np[i].replace(/(^|[^,])\s*-/g, '$1,-').replace(/(\s+\,|\s|\,)/g,',').replace(r,'').split(',');
np[i][0] = parseFloat(np[i][0]);
np[i][1] = parseFloat(np[i][1]);
- if (i === 0) { x+=np[i][0]; y +=np[i][1]; }
+ if (i === 0) { x+=np[i][0]; y +=np[i][1]; }
else {
x = np[i-1][0];
y = np[i-1][1];
@@ -234,23 +241,16 @@
}
return np;
}
-
- // a shortHand pathCross
- K.svq = function(w){ if ( w._vE.path ) S.pCr(w); }
+
+ // a shortHand pathCross && SVG transform stack
+ K.svq = function(w){ if ( w._vE.path ) S.pCr(w); if ( w._vE.svgTransform ) S.sT(w); }
// register the render SVG path object
// process path object and also register the render function
K.pp['path'] = function(a,o,l) { // K.pp['path']('path',value,element);
- if (!('path' in K.dom)) {
- K.dom['path'] = function(w,p,v){
- var points =[], i, l;
- for(i=0,l=w._vE.path.d.length;i 1) {
var coord = function (p) {
@@ -373,30 +369,16 @@
var rx = el.getAttribute('rx'), ry = el.getAttribute('ry'),
len = 2*rx, wid = 2*ry;
return ((Math.sqrt(.5 * ((len * len) + (wid * wid)))) * (Math.PI * 2)) / 2;
- }
-
+ }
// SVG CSS Color Properties
for ( var i = 0, l = _cls.length; i< l; i++) {
p = _cls[i];
- K.pp[p] = function(p,v){
- if (!(p in K.dom)) {
- K.dom[p] = function(w,p,v){
- var _c = {};
- for (var c in w._vE[p]) {
- if ( c !== 'a' ){
- _c[c] = parseInt(w._vS[p][c] + (w._vE[p][c] - w._vS[p][c]) * v )||0;
- } else {
- _c[c] = (w._vS[p][c] && w._vE[p][c]) ? parseFloat(w._vS[p][c] + (w._vE[p][c] - w._vS[p][c]) * v) : null;
- }
- }
-
- if ( w._hex ) {
- w._el.style[p] = K.rth( _c.r, _c.g, _c.b );
- } else {
- w._el.style[p] = !_c.a ? 'rgb(' + _c.r + ',' + _c.g + ',' + _c.b + ')' : 'rgba(' + _c.r + ',' + _c.g + ',' + _c.b + ',' + _c.a + ')';
- }
- }
+ PP[p] = function(p,v){
+ if (!(p in DOM)) {
+ DOM[p] = function(l,p,a,b,v,o) {
+ l.style[p] = color(a,b,v,o.keepHex);
+ };
}
return K.truC(v);
}
@@ -404,23 +386,25 @@
return K.gCS(el,p) || 'rgba(0,0,0,0)';
}
}
+
for ( var i = 0, l = _nm.length; i< l; i++) { // for numeric CSS props from any type of SVG shape
p = _nm[i];
- if (p === 'strokeWidth'){
- K.pp[p] = function(p,v){
- if (!(p in K.dom)) {
- K.dom[p] = function(w,p,v) {
- w._el.style[p] = (w._vS[p].value + (w._vE[p].value - w._vS[p].value) * v) + w._vS[p].unit;
+ if (p === 'strokeWidth'){ // stroke can be unitless or unit | http://stackoverflow.com/questions/1301685/fixed-stroke-width-in-svg
+ PP[p] = function(p,v){
+ if (!(p in DOM)) {
+ DOM[p] = function(l,p,a,b,v) {
+ var _u = _u || typeof b === 'number';
+ l.style[p] = !_u ? unit(a.value,b.value,b.unit,v) : number(a,b,v);
}
}
- return K.pp.box(p,v);
+ return /px|%|em|vh|vw/.test(v) ? PP.box(p,v) : parseFloat(v);
}
} else {
- K.pp[p] = function(p,v){
- if (!(p in K.dom)) {
- K.dom[p] = function(w,p,v) {
- w._el.style[p] = w._vS[p] + (w._vE[p] - w._vS[p]) * v;
+ PP[p] = function(p,v){
+ if (!(p in DOM)) {
+ DOM[p] = function(l,p,a,b,v) {
+ l.style[p] = number(a,b,v);
}
}
return parseFloat(v);
@@ -432,72 +416,115 @@
}
// SVG Transform
- K.pp['svgTransform'] = function(p,v,l){
+ PP['svgTransform'] = function(p,v,l){
// register the render function
- if (!('svgTransform' in K.dom)) {
- K.dom['svgTransform'] = function(w,p,v) {
+ if (!('svgTransform' in DOM)) {
+ DOM['svgTransform'] = function(l,p,a,b,v){
var tr = '', i;
- for (i in w._vE[p]){
+ for (i in b){
tr += i + '('; // start string
if ( i === 'translate'){ // translate
- tr += (w._vS[p][i][1] === w._vE[p][i][1] && w._vE[p][i][1] === 0 )
- ? (w._vS[p][i][0] + (w._vE[p][i][0] - w._vS[p][i][0]) * v )
- : (w._vS[p][i][0] + (w._vE[p][i][0] - w._vS[p][i][0]) * v ) + ' ' + (w._vS[p][i][1] + (w._vE[p][i][1] - w._vS[p][i][1]) * v );
+ tr += (a[i][1] === b[i][1] && b[i][1] === 0 )
+ ? number(a[i][0],b[i][0],v)
+ : number(a[i][0],b[i][0],v) + ' ' + number(a[i][1],b[i][1],v);
} else if ( i === 'rotate'){ // rotate
- tr += w._vS[p][i][0] + (w._vE[p][i][0] - w._vS[p][i][0]) * v + ' ';
- tr += !w.reversed ? w._vE[p][i][1] + ',' + w._vE[p][i][2] : w._vS[p][i][1] + ',' + w._vS[p][i][2]; // make sure to always use the right transform-origin
+ tr += number(a[i][0],b[i][0],v) + ' ';
+ tr += b[i][1] + ',' + b[i][2];
} else { // scale, skewX or skewY
- tr += w._vS[p][i] + (w._vE[p][i] - w._vS[p][i]) * v;
+ tr += number(a[i],b[i],v);
}
tr += ') '; // end string
}
- w._el.setAttributeNS(null,'transform', tr.replace(/\)\s$/,')') );
+ l.setAttribute('transform', tr.trim() );
}
}
- // return transform object
- var tf = {}, bb = l.getBBox(), cx = bb.x + bb.width/2, cy = bb.y + bb.height/2, i, r, t;
- for ( i in v ) {
+ // now prepare transform
+ var tf = {}, bb = l.getBBox(), cx = bb.x + bb.width/2, cy = bb.y + bb.height/2, r, cr, t, ct;
+
+ for ( i in v ) { // populate the valuesStart and / or valuesEnd
if (i === 'rotate'){
- r = v[i] instanceof Array ? v[i]
+ r = v[i] instanceof Array ? v[i]
: /\s/.test(v[i]) ? [v[i].split(' ')[0]*1, v[i].split(' ')[1].split(',')[0]*1, v[i].split(' ')[1].split(',')[1]*1]
- : [v[i],cx,cy];
+ : [v[i]*1,cx,cy];
tf[i] = r;
} else if (i === 'translate'){
- t = v[i] instanceof Array ? v[i] : /\s/.test(v[i]) ? v[i].split(' ') : [v[i],0];
- tf[i] = [t[0] * 1||0, t[1] * 1];
+ t = v[i] instanceof Array ? v[i] : /\,|\s/.test(v[i]) ? v[i].split(/\,|\s/) : [v[i]*1,0];
+ tf[i] = [t[0] * 1||0, t[1] * 1||0];
} else if (i === 'scale'){
tf[i] = v[i] * 1||1;
- } else {
+ } else if (/skew/.test(i)) {
tf[i] = v[i] * 1||0;
}
}
+ // try to adjust translation when scale is used, probably we should do the same when using skews, but I think it's a waste of time
// http://www.petercollingridge.co.uk/interactive-svg-components/pan-and-zoom-control
- // try to adjust translation when scale is used
if ('scale' in tf) {
- tf['translate'] = !( 'translate' in tf ) ? [0,0] : tf['translate'];
- tf['translate'][0] += (1-tf['scale']) * bb.width/2;
+ !('translate' in tf) && ( tf['translate'] = [0,0] ); // if no translate is found in current value or next value, we default to 0
+ tf['translate'][0] += (1-tf['scale']) * bb.width/2;
tf['translate'][1] += (1-tf['scale']) * bb.height/2;
- }
+ // adjust rotation transform origin and translation when skews are used, to make the animation look exactly the same as if we were't using svgTransform
+ // http://stackoverflow.com/questions/39191054/how-to-compensate-translate-when-skewx-and-skewy-are-used-on-svg/39192565#39192565
+ if ('rotate' in tf) {
+ tf['rotate'][1] -= 'skewX' in tf ? Math.tan(tf['skewX']) * bb.height : 0;
+ tf['rotate'][2] -= 'skewY' in tf ? Math.tan(tf['skewY']) * bb.width : 0;
+ }
+ tf['translate'][0] += 'skewX' in tf ? Math.tan(tf['skewX']) * bb.height*2 : 0;
+ tf['translate'][1] += 'skewY' in tf ? Math.tan(tf['skewY']) * bb.width*2 : 0;
+ } // more variations here https://gist.github.com/thednp/0b93068e20adb84658b5840ead0a07f8
+
return tf;
}
// KUTE.prepareStart K.prS[p](el,p,to[p])
// returns an obect with current transform attribute value
K.prS['svgTransform'] = function(l,p,t) {
- var tr = {}, cta = l.getAttributeNS(null,'transform'),
- ct = cta && /\)/.test(cta) ? cta.split(')') : 'none', i, j, ctr ={}, pr;
- if (ct instanceof Array) {
- for (j=0; j,./?\=-").split(""), // symbols
_n = String("0123456789").split(""), // numeric
_a = _s.concat(_S,_n), // alpha numeric
_all = _a.concat(_sb), // all caracters
- _r = Math.random, _f = Math.floor, _m = Math.min;
+ random = Math.random, floor = Math.floor, min = Math.min;
K.prS['text'] = K.prS['number'] = function(l,p,v){
return l.innerHTML;
}
- K.pp['text'] = function(p,v,l) {
- if ( !( 'text' in K.dom ) ) {
- K.dom['text'] = function(w,p,v) {
- var tp = tp || w.textChars === 'alpha' ? _s // textChars is alpha
- : w.textChars === 'upper' ? _S // textChars is numeric
- : w.textChars === 'numeric' ? _n // textChars is numeric
- : w.textChars === 'alphanumeric' ? _a // textChars is alphanumeric
- : w.textChars === 'symbols' ? _sb // textChars is symbols
- : w.textChars ? w.textChars.split('') // textChars is a custom text
- : _s, l = tp.length, s = w._vE[p],
- t = tp[_f((_r() * l))], tx = '', f = s.substring(0);
+ PP['text'] = function(p,v,l) {
+ if ( !( 'text' in DOM ) ) {
+ DOM['text'] = function(l,p,a,b,v,o) {
+ var tp = tp || o.textChars === 'alpha' ? _s // textChars is alpha
+ : o.textChars === 'upper' ? _S // textChars is numeric
+ : o.textChars === 'numeric' ? _n // textChars is numeric
+ : o.textChars === 'alphanumeric' ? _a // textChars is alphanumeric
+ : o.textChars === 'symbols' ? _sb // textChars is symbols
+ : o.textChars ? o.textChars.split('') // textChars is a custom text
+ : _s, ll = tp.length,
+ t = tp[floor((random() * ll))], ix = '', tx = '', fi = a.substring(0), f = b.substring(0);
- tx = f.substring(0,_f(_m(v * f.length, f.length)));
- w._el.innerHTML = v < 1 ? tx+t : tx;
+ // use string.replace(/<\/?[^>]+(>|$)/g, "") to strip HTML tags while animating ?
+ ix = a !== '' ? fi.substring(fi.length,floor(min(v * fi.length, fi.length))) : ''; // initial text, A value
+ tx = f.substring(0,floor(min(v * f.length, f.length))); // end text, B value
+ l.innerHTML = v < 1 ? tx + t + ix : b;
}
}
return v;
}
- K.pp['number'] = function(p,v,l) {
- if ( !( 'number' in K.dom ) ) {
- K.dom['number'] = function(w,p,v) {
- w._el.innerHTML = parseInt(w._vS[p] + (w._vE[p] - w._vS[p]) * v);
+ PP['number'] = function(p,v,l) {
+ if ( !( 'number' in DOM ) ) {
+ DOM['number'] = function(l,p,a,b,v) {
+ l.innerHTML = parseInt( number(a, b, v));
}
}
return parseInt(v) || 0;
diff --git a/kute.js b/kute.js
index c82329b..5ed87f7 100644
--- a/kute.js
+++ b/kute.js
@@ -13,37 +13,137 @@
}
}( function () {
"use strict";
- var K = K || {}, _tws = [], _t, _min = Math.min;
+ var K = K || {}, _tws = [], _t = null,
- K.getPrefix = function() { //returns browser prefix
- var div = document.createElement('div'), i = 0, pf = ['Moz', 'moz', 'Webkit', 'webkit', 'O', 'o', 'Ms', 'ms'], pl = pf.length,
- s = ['MozTransform', 'mozTransform', 'WebkitTransform', 'webkitTransform', 'OTransform', 'oTransform', 'MsTransform', 'msTransform'];
- for (i; i < pl; i++) { if (s[i] in div.style) { return pf[i]; } }
- div = null;
- };
-
- K.property = function(p){ // returns prefixed property | property
- var r = (!(p in document.body.style)) ? true : false, f = K.getPrefix(); // is prefix required for property | prefix
- return r ? f + (p.charAt(0).toUpperCase() + p.slice(1)) : p;
- };
-
- K.selector = function(el,multi){ // a selector utility
- var nl;
- if (multi){
- nl = el instanceof NodeList ? el : document.querySelectorAll(el);
- } else {
- nl = typeof el === 'object' ? el : /^#/.test(el) ? document.getElementById(el.replace('#','')) : document.querySelector(el);
- }
- if (nl === null && el !== 'window') throw new TypeError('Element not found or incorrect selector: '+el);
- return nl;
- };
-
- var _tch = ('ontouchstart' in window || navigator.msMaxTouchPoints) || false, // support Touch?
+ getPrefix = function() { //returns browser prefix
+ var div = document.createElement('div'), i = 0, pf = ['Moz', 'moz', 'Webkit', 'webkit', 'O', 'o', 'Ms', 'ms'], pl = pf.length,
+ s = ['MozTransform', 'mozTransform', 'WebkitTransform', 'webkitTransform', 'OTransform', 'oTransform', 'MsTransform', 'msTransform'];
+ for (i; i < pl; i++) { if (s[i] in div.style) { return pf[i]; } }
+ div = null;
+ },
+ property = function(p){ // returns prefixed property | property
+ var r = (!(p in document.body.style)) ? true : false, f = getPrefix(); // is prefix required for property | prefix
+ return r ? f + (p.charAt(0).toUpperCase() + p.slice(1)) : p;
+ },
+ selector = function(el,multi){ // a selector utility
+ var nl;
+ if (multi){
+ nl = el instanceof NodeList ? el : document.querySelectorAll(el);
+ } else {
+ nl = typeof el === 'object' ? el
+ : /^#/.test(el) ? document.getElementById(el.replace('#','')) : document.querySelector(el);
+ }
+ if (nl === null && el !== 'window') throw new TypeError('Element not found or incorrect selector: '+el);
+ return nl;
+ },
+ trueDimendion = function (d,p) { //true dimension returns { v = value, u = unit }
+ var x = parseInt(d) || 0, mu = ['px','%','deg','rad','em','rem','vh','vw'], l = mu.length,
+ y = getU();
+ function getU() {
+ var u,i=0;
+ for (i;i 0) {
- if ( w._r < 9999 ) { w._r--; }
+ if ( w._r < 9999 ) { w._r--; } // we have to make it stop somewhere, infinity is too damn much
if (w._y) { w.reversed = !w.reversed; w.rvs(); } // handle yoyo
@@ -130,8 +253,7 @@
if (w._cC) { w._cC.call(); }
- //stop preventing scroll when scroll tween finished
- w.scrollOut();
+ w.scrollOut(); // unbind preventing scroll when scroll tween finished
// start animating chained tweens
var i = 0, ctl = w._cT.length;
@@ -145,41 +267,25 @@
}
}
return true;
- };
-
- // internal ticker
- K._tk = function (t) {
- var i = 0, tl;
- _t = _raf(K._tk);
- while ( i < (tl = _tws.length) ) {
- if ( K._u(_tws[i],t) ) {
- i++;
- } else {
- _tws.splice(i, 1);
- }
- }
- };
-
- // aplies the transform origin and perspective
- K.perspective = function (l,w) {
+ },
+
+ // applies the transform origin and perspective
+ perspective = function (l,w) {
if ( w._to !== undefined ) { l.style[_pfto] = w._to; } // element transform origin
if ( w._ppo !== undefined ) { l.style[_pfo] = w._ppo; } // element perspective origin
if ( w._ppp !== undefined ) { l.parentNode.style[_pfp] = w._ppp + 'px'; } // parent perspective
if ( w._pppo !== undefined ) { l.parentNode.style[_pfo] = w._pppo; } // parent perspective origin
- };
+ },
//more internals
- K.getAll = function () { return _tws; };
- K.removeAll = function () { _tws = []; };
- K.add = function (tw) { _tws.push(tw); };
- K.remove = function (tw) {
- var i = _tws.indexOf(tw);
- if (i !== -1) { _tws.splice(i, 1); }
- };
- K.s = function () { _caf(_t); _t = null; };
+ getAll = function () { return _tws; },
+ removeAll = function () { _tws = []; },
+ add = function (tw) { _tws.push(tw); },
+ remove = function (tw) { var i = _tws.indexOf(tw); if (i !== -1) { _tws.splice(i, 1); }},
+ stop = function () { _t && _caf(_t); _t = null; },
// process properties for _vE and _vS or one of them
- K.prP = function (e, s, l) {
+ preparePropertiesObject = function (e, s, l) {
var i, pl = arguments.length, _st = []; pl = pl > 2 ? 2 : pl;
for (i=0; i 0) { self._r = self.repeat; }
- if (self._y && self.reversed===true) { self.rvs(); self.reversed = false; }
- self.playing = false;
- },64)
- };
+
+ this.close = function () {
+ var self = this;
+ setTimeout(function(){
+ var i = _tws.indexOf(self);
+ if (i === _tws.length-1) { stop(); }
+ if (self.repeat > 0) { self._r = self.repeat; }
+ if (self._y && self.reversed===true) { self.rvs(); self.reversed = false; }
+ self.playing = false;
+ },64)
+ }
+ },
// the multi elements Tween constructs
- K.TweensTO = function (els, vE, o) { // .to
+ TweensTO = function (els, vE, o) { // .to
this.tweens = []; var i, tl = els.length, _o = [];
for ( i = 0; i < tl; i++ ) {
_o[i] = o || {}; o.delay = o.delay || 0;
_o[i].delay = i>0 ? o.delay + (o.offset||0) : o.delay;
- this.tweens.push( K.to(els[i], vE, _o[i]) );
+ this.tweens.push( to(els[i], vE, _o[i]) );
}
- };
- K.TweensFT = function (els, vS, vE, o) { // .fromTo
+ },
+ TweensFT = function (els, vS, vE, o) { // .fromTo
this.tweens = []; var i, tl = els.length, _o = [];
for ( i = 0; i < tl; i++ ) {
_o[i] = o || {}; o.delay = o.delay || 0;
_o[i].delay = i>0 ? o.delay + (o.offset||0) : o.delay;
- this.tweens.push( K.fromTo(els[i], vS, vE, _o[i]) );
+ this.tweens.push( fromTo(els[i], vS, vE, _o[i]) );
}
};
- var ws = K.TweensTO.prototype = K.TweensFT.prototype;
+
+ var ws = TweensTO.prototype = TweensFT.prototype;
ws.start = function(t){
t = t || window.performance.now();
var i, tl = this.tweens.length;
@@ -799,5 +733,53 @@
ws.chain = function(){ this.tweens[this.tweens.length-1]._cT = arguments; return this; }
ws.play = ws.resume = function(){ for ( var i = 0; i < this.tweens.length; i++ ) { this.tweens[i].play(); } return this; }
+ var start = function (t) { // move functions that use the ticker outside the prototype to be in the same scope with it
+ this.scrollIn();
+
+ perspective(this._el,this); // apply the perspective and transform origin
+ if ( this._rpr ) { this.stack(); } // on start we reprocess the valuesStart for TO() method
+
+ for ( var e in this._vE ) {
+ this._vSR[e] = this._vS[e];
+ }
+
+ // now it's a good time to start
+ add(this);
+ this.playing = true;
+ this.paused = false;
+ this._sCF = false;
+ this._sT = t || window.performance.now();
+ this._sT += this._dl;
+
+ if (!this._sCF) {
+ if (this._sC) { this._sC.call(); }
+ this._sCF = true;
+ }
+ if (!_t) _tk();
+ return this;
+ },
+ play = function () {
+ if (this.paused && this.playing) {
+ this.paused = false;
+ if (this._rC !== null) { this._rC.call(); }
+ this._sT += window.performance.now() - this._pST;
+ add(this);
+ if (!_t) _tk(); // restart ticking if stopped
+ }
+ return this;
+ };
+ Tween.prototype.start = start;
+ Tween.prototype.play = Tween.prototype.resume = play;
+
+ K = { // export core methods to public for plugins
+ property: property, getPrefix: getPrefix, selector: selector, pe : pe, // utils
+ to: to, fromTo: fromTo, allTo: allTo, allFromTo: allFromTo, // main methods
+ Interpolate: {number: number, unit: unit, color: color }, // interpolators ?? move array & coords to svg and leave color
+ dom: DOM, // DOM manipulation
+ pp: parseProperty, prS: prepareStart, // init
+ truD: trueDimendion, truC: trueColor, rth: rgbToHex, htr: hexToRGB, gCS: getComputedStyle, // property parsing
+ Easing: easing,
+ Tween: Tween, TweensTO: TweensTO, TweensFT: TweensFT // constructors
+ };
return K;
}));
\ No newline at end of file