Removed some recursion from plugins.
This commit is contained in:
parent
72dea56f33
commit
21210c2dd7
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "KUTE.js",
|
||||
"version": "1.5.95",
|
||||
"version": "1.5.96",
|
||||
"homepage": "http://thednp.github.io/kute.js",
|
||||
"authors": [
|
||||
"thednp"
|
||||
|
|
2
demo/src/kute-css.min.js
vendored
2
demo/src/kute-css.min.js
vendored
|
@ -1,2 +1,2 @@
|
|||
// KUTE.js v1.5.95 | © dnp_theme | CSS Plugin | MIT-License
|
||||
!function(t,r){if("function"==typeof define&&define.amd)define(["kute.js"],r);else if("object"==typeof module&&"function"==typeof require)module.exports=r(require("kute.js"));else{if("undefined"==typeof t.KUTE)throw new Error("CSS Plugin require KUTE.js.");r(t.KUTE)}}(this,function(t){"use strict";for(var r="undefined"!=typeof global?global:window,o=t,e=r.dom,i=o.pp,n=o.prS,d=o.gCS,u=o.truD,a=o.property("borderRadius"),f=o.property("borderTopLeftRadius"),p=o.property("borderTopRightRadius"),g=o.property("borderBottomLeftRadius"),l=o.property("borderBottomRightRadius"),c=["borderColor","borderTopColor","borderRightColor","borderBottomColor","borderLeftColor","outlineColor"],s=["borderRadius","borderTopLeftRadius","borderTopRightRadius","borderBottomLeftRadius","borderBottomRightRadius"],b=["right","bottom","minWidth","minHeight","maxWidth","maxHeight","padding","margin","paddingTop","paddingBottom","paddingLeft","paddingRight","marginTop","marginBottom","marginLeft","marginRight","borderWidth","borderTopWidth","borderRightWidth","borderBottomWidth","borderLeftWidth","outlineWidth"],h=["fontSize","lineHeight","letterSpacing","wordSpacing"],v=["clip"],m=["backgroundPosition"],R=s.concat(b,h),y=c.concat(v,s,b,h,m),T=y.length,x=(r.Interpolate.number,r.Interpolate.unit),B=B||{},L=0;L<T;L++){var C=y[L];c.indexOf(C)!==-1?B[C]="rgba(0,0,0,0)":R.indexOf(C)!==-1?B[C]=0:m.indexOf(C)!==-1?B[C]=[50,50]:"clip"===C&&(B[C]=[0,0,0,0])}for(var L=0,W=c.length;L<W;L++)C=c[L],i[C]=function(t,r){return i.cls(t,r)},n[C]=function(t,r,o){return d(t,r)||B[r]};for(var L=0,W=R.length;L<W;L++)C=R[L],i[C]=function(t,r){return i.box(t,r)},n[C]=function(t,r,o){return d(t,r)||B[r]};for(var L=0,W=s.length;L<W;L++)C=s[L],i[C]=function(t,r){return t in e||("borderRadius"===t?e[t]=function(t,r,o,e,i){t.style[a]=x(o.v,e.v,e.u,i)}:"borderTopLeftRadius"===t?e[t]=function(t,r,o,e,i){t.style[f]=x(o.v,e.v,e.u,i)}:"borderTopRightRadius"===t?e[t]=function(t,r,o,e,i){t.style[p]=x(o.v,e.v,e.u,i)}:"borderBottomLeftRadius"===t?e[t]=function(t,r,o,e,i){t.style[g]=x(o.v,e.v,e.u,i)}:"borderBottomRightRadius"===t&&(e[t]=function(t,r,o,e,i){t.style[l]=x(o.v,e.v,e.u,i)})),u(r)},n[C]=function(t,r,o){return d(t,r)||B[r]};return i.clip=function(t,r){if(t in e||(e[t]=function(t,r,o,e,i){var n=0,d=[];for(n;n<4;n++){var u=o[n].v,a=e[n].v,f=e[n].u||"px";d[n]=x(u,a,f,i)}t.style[r]="rect("+d+")"}),r instanceof Array)return[u(r[0]),u(r[1]),u(r[2]),u(r[3])];var o=r.replace(/rect|\(|\)/g,"");return o=/\,/g.test(o)?o.split(/\,/g):o.split(/\s/g),[u(o[0]),u(o[1]),u(o[2]),u(o[3])]},n.clip=function(t,r,o){var e=d(t,r),i=d(t,"width"),n=d(t,"height");return/rect/.test(e)?e:[0,i,n,0]},i.backgroundPosition=function(t,r){if(t in e||(e[t]=function(t,r,o,e,i){t.style[r]=x(o.x.v,e.x.v,"%",i)+" "+x(o.y.v,e.y.v,"%",i)}),r instanceof Array)return{x:u(r[0])||{v:50,u:"%"},y:u(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=u(n[0]),i=u(n[1]),{x:o,y:i}},n.backgroundPosition=function(t,r,o){return d(t,r)||B[r]},this});
|
||||
!function(t,r){if("function"==typeof define&&define.amd)define(["kute.js"],r);else if("object"==typeof module&&"function"==typeof require)module.exports=r(require("kute.js"));else{if("undefined"==typeof t.KUTE)throw new Error("CSS Plugin require KUTE.js.");r(t.KUTE)}}(this,function(t){"use strict";for(var r="undefined"!=typeof global?global:window,e=t,o=r.dom,i=e.pp,n=e.prS,d=e.gCS,u=e.truD,f=e.truC,a=e.property("borderRadius"),p=e.property("borderTopLeftRadius"),g=e.property("borderTopRightRadius"),l=e.property("borderBottomLeftRadius"),c=e.property("borderBottomRightRadius"),s=["borderColor","borderTopColor","borderRightColor","borderBottomColor","borderLeftColor","outlineColor"],b=["borderRadius","borderTopLeftRadius","borderTopRightRadius","borderBottomLeftRadius","borderBottomRightRadius"],h=["right","bottom","minWidth","minHeight","maxWidth","maxHeight","padding","margin","paddingTop","paddingBottom","paddingLeft","paddingRight","marginTop","marginBottom","marginLeft","marginRight","borderWidth","borderTopWidth","borderRightWidth","borderBottomWidth","borderLeftWidth","outlineWidth"],v=["fontSize","lineHeight","letterSpacing","wordSpacing"],m=["clip"],y=["backgroundPosition"],R=b.concat(h,v),T=s.concat(m,b,h,v,y),x=T.length,B=(r.Interpolate.number,r.Interpolate.unit),L=r.Interpolate.color,C=C||{},W=0;W<x;W++)s.indexOf(T[W])!==-1?C[T[W]]="rgba(0,0,0,0)":R.indexOf(T[W])!==-1?C[T[W]]=0:y.indexOf(T[W])!==-1?C[T[W]]=[50,50]:"clip"===T[W]&&(C[T[W]]=[0,0,0,0]);for(var W=0,S=s.length;W<S;W++)i[s[W]]=function(t,r){return t in o||(o[t]=function(t,r,e,o,i,n){t.style[r]=L(e,o,i,n.keepHex)}),f(r)},n[s[W]]=function(t,r,e){return d(t,r)||C[r]};for(var W=0,S=R.length;W<S;W++)i[R[W]]=function(t,r){return t in o||(o[t]=function(t,r,e,o,i){t.style[r]=B(e.v,o.v,o.u,i)}),u(r)},n[R[W]]=function(t,r,e){return d(t,r)||C[r]};for(var W=0,S=b.length;W<S;W++)i[b[W]]=function(t,r){return t in o||("borderRadius"===t?o[t]=function(t,r,e,o,i){t.style[a]=B(e.v,o.v,o.u,i)}:"borderTopLeftRadius"===t?o[t]=function(t,r,e,o,i){t.style[p]=B(e.v,o.v,o.u,i)}:"borderTopRightRadius"===t?o[t]=function(t,r,e,o,i){t.style[g]=B(e.v,o.v,o.u,i)}:"borderBottomLeftRadius"===t?o[t]=function(t,r,e,o,i){t.style[l]=B(e.v,o.v,o.u,i)}:"borderBottomRightRadius"===t&&(o[t]=function(t,r,e,o,i){t.style[c]=B(e.v,o.v,o.u,i)})),u(r)},n[b[W]]=function(t,r,e){return d(t,r)||C[r]};return i.clip=function(t,r){if(t in o||(o[t]=function(t,r,e,o,i){var n=0,d=[];for(n;n<4;n++){var u=e[n].v,f=o[n].v,a=o[n].u||"px";d[n]=B(u,f,a,i)}t.style[r]="rect("+d+")"}),r instanceof Array)return[u(r[0]),u(r[1]),u(r[2]),u(r[3])];var e=r.replace(/rect|\(|\)/g,"");return e=/\,/g.test(e)?e.split(/\,/g):e.split(/\s/g),[u(e[0]),u(e[1]),u(e[2]),u(e[3])]},n.clip=function(t,r,e){var o=d(t,r),i=d(t,"width"),n=d(t,"height");return/rect/.test(o)?o:[0,i,n,0]},i.backgroundPosition=function(t,r){if(t in o||(o[t]=function(t,r,e,o,i){t.style[r]=B(e.x.v,o.x.v,"%",i)+" "+B(e.y.v,o.y.v,"%",i)}),r instanceof Array)return{x:u(r[0])||{v:50,u:"%"},y:u(r[1])||{v:50,u:"%"}};var e,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],e=u(n[0]),i=u(n[1]),{x:e,y:i}},n.backgroundPosition=function(t,r,e){return d(t,r)||C[r]},this});
|
2
demo/src/kute-svg.min.js
vendored
2
demo/src/kute-svg.min.js
vendored
File diff suppressed because one or more lines are too long
2
demo/src/kute.min.js
vendored
2
demo/src/kute.min.js
vendored
File diff suppressed because one or more lines are too long
2
dist/kute-css.min.js
vendored
2
dist/kute-css.min.js
vendored
|
@ -1,2 +1,2 @@
|
|||
// KUTE.js v1.5.95 | © dnp_theme | CSS Plugin | MIT-License
|
||||
!function(t,r){if("function"==typeof define&&define.amd)define(["kute.js"],r);else if("object"==typeof module&&"function"==typeof require)module.exports=r(require("kute.js"));else{if("undefined"==typeof t.KUTE)throw new Error("CSS Plugin require KUTE.js.");r(t.KUTE)}}(this,function(t){"use strict";for(var r="undefined"!=typeof global?global:window,o=t,e=r.dom,i=o.pp,n=o.prS,d=o.gCS,u=o.truD,a=o.property("borderRadius"),f=o.property("borderTopLeftRadius"),p=o.property("borderTopRightRadius"),g=o.property("borderBottomLeftRadius"),l=o.property("borderBottomRightRadius"),c=["borderColor","borderTopColor","borderRightColor","borderBottomColor","borderLeftColor","outlineColor"],s=["borderRadius","borderTopLeftRadius","borderTopRightRadius","borderBottomLeftRadius","borderBottomRightRadius"],b=["right","bottom","minWidth","minHeight","maxWidth","maxHeight","padding","margin","paddingTop","paddingBottom","paddingLeft","paddingRight","marginTop","marginBottom","marginLeft","marginRight","borderWidth","borderTopWidth","borderRightWidth","borderBottomWidth","borderLeftWidth","outlineWidth"],h=["fontSize","lineHeight","letterSpacing","wordSpacing"],v=["clip"],m=["backgroundPosition"],R=s.concat(b,h),y=c.concat(v,s,b,h,m),T=y.length,x=(r.Interpolate.number,r.Interpolate.unit),B=B||{},L=0;L<T;L++){var C=y[L];c.indexOf(C)!==-1?B[C]="rgba(0,0,0,0)":R.indexOf(C)!==-1?B[C]=0:m.indexOf(C)!==-1?B[C]=[50,50]:"clip"===C&&(B[C]=[0,0,0,0])}for(var L=0,W=c.length;L<W;L++)C=c[L],i[C]=function(t,r){return i.cls(t,r)},n[C]=function(t,r,o){return d(t,r)||B[r]};for(var L=0,W=R.length;L<W;L++)C=R[L],i[C]=function(t,r){return i.box(t,r)},n[C]=function(t,r,o){return d(t,r)||B[r]};for(var L=0,W=s.length;L<W;L++)C=s[L],i[C]=function(t,r){return t in e||("borderRadius"===t?e[t]=function(t,r,o,e,i){t.style[a]=x(o.v,e.v,e.u,i)}:"borderTopLeftRadius"===t?e[t]=function(t,r,o,e,i){t.style[f]=x(o.v,e.v,e.u,i)}:"borderTopRightRadius"===t?e[t]=function(t,r,o,e,i){t.style[p]=x(o.v,e.v,e.u,i)}:"borderBottomLeftRadius"===t?e[t]=function(t,r,o,e,i){t.style[g]=x(o.v,e.v,e.u,i)}:"borderBottomRightRadius"===t&&(e[t]=function(t,r,o,e,i){t.style[l]=x(o.v,e.v,e.u,i)})),u(r)},n[C]=function(t,r,o){return d(t,r)||B[r]};return i.clip=function(t,r){if(t in e||(e[t]=function(t,r,o,e,i){var n=0,d=[];for(n;n<4;n++){var u=o[n].v,a=e[n].v,f=e[n].u||"px";d[n]=x(u,a,f,i)}t.style[r]="rect("+d+")"}),r instanceof Array)return[u(r[0]),u(r[1]),u(r[2]),u(r[3])];var o=r.replace(/rect|\(|\)/g,"");return o=/\,/g.test(o)?o.split(/\,/g):o.split(/\s/g),[u(o[0]),u(o[1]),u(o[2]),u(o[3])]},n.clip=function(t,r,o){var e=d(t,r),i=d(t,"width"),n=d(t,"height");return/rect/.test(e)?e:[0,i,n,0]},i.backgroundPosition=function(t,r){if(t in e||(e[t]=function(t,r,o,e,i){t.style[r]=x(o.x.v,e.x.v,"%",i)+" "+x(o.y.v,e.y.v,"%",i)}),r instanceof Array)return{x:u(r[0])||{v:50,u:"%"},y:u(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=u(n[0]),i=u(n[1]),{x:o,y:i}},n.backgroundPosition=function(t,r,o){return d(t,r)||B[r]},this});
|
||||
!function(t,r){if("function"==typeof define&&define.amd)define(["kute.js"],r);else if("object"==typeof module&&"function"==typeof require)module.exports=r(require("kute.js"));else{if("undefined"==typeof t.KUTE)throw new Error("CSS Plugin require KUTE.js.");r(t.KUTE)}}(this,function(t){"use strict";for(var r="undefined"!=typeof global?global:window,e=t,o=r.dom,i=e.pp,n=e.prS,d=e.gCS,u=e.truD,f=e.truC,a=e.property("borderRadius"),p=e.property("borderTopLeftRadius"),g=e.property("borderTopRightRadius"),l=e.property("borderBottomLeftRadius"),c=e.property("borderBottomRightRadius"),s=["borderColor","borderTopColor","borderRightColor","borderBottomColor","borderLeftColor","outlineColor"],b=["borderRadius","borderTopLeftRadius","borderTopRightRadius","borderBottomLeftRadius","borderBottomRightRadius"],h=["right","bottom","minWidth","minHeight","maxWidth","maxHeight","padding","margin","paddingTop","paddingBottom","paddingLeft","paddingRight","marginTop","marginBottom","marginLeft","marginRight","borderWidth","borderTopWidth","borderRightWidth","borderBottomWidth","borderLeftWidth","outlineWidth"],v=["fontSize","lineHeight","letterSpacing","wordSpacing"],m=["clip"],y=["backgroundPosition"],R=b.concat(h,v),T=s.concat(m,b,h,v,y),x=T.length,B=(r.Interpolate.number,r.Interpolate.unit),L=r.Interpolate.color,C=C||{},W=0;W<x;W++)s.indexOf(T[W])!==-1?C[T[W]]="rgba(0,0,0,0)":R.indexOf(T[W])!==-1?C[T[W]]=0:y.indexOf(T[W])!==-1?C[T[W]]=[50,50]:"clip"===T[W]&&(C[T[W]]=[0,0,0,0]);for(var W=0,S=s.length;W<S;W++)i[s[W]]=function(t,r){return t in o||(o[t]=function(t,r,e,o,i,n){t.style[r]=L(e,o,i,n.keepHex)}),f(r)},n[s[W]]=function(t,r,e){return d(t,r)||C[r]};for(var W=0,S=R.length;W<S;W++)i[R[W]]=function(t,r){return t in o||(o[t]=function(t,r,e,o,i){t.style[r]=B(e.v,o.v,o.u,i)}),u(r)},n[R[W]]=function(t,r,e){return d(t,r)||C[r]};for(var W=0,S=b.length;W<S;W++)i[b[W]]=function(t,r){return t in o||("borderRadius"===t?o[t]=function(t,r,e,o,i){t.style[a]=B(e.v,o.v,o.u,i)}:"borderTopLeftRadius"===t?o[t]=function(t,r,e,o,i){t.style[p]=B(e.v,o.v,o.u,i)}:"borderTopRightRadius"===t?o[t]=function(t,r,e,o,i){t.style[g]=B(e.v,o.v,o.u,i)}:"borderBottomLeftRadius"===t?o[t]=function(t,r,e,o,i){t.style[l]=B(e.v,o.v,o.u,i)}:"borderBottomRightRadius"===t&&(o[t]=function(t,r,e,o,i){t.style[c]=B(e.v,o.v,o.u,i)})),u(r)},n[b[W]]=function(t,r,e){return d(t,r)||C[r]};return i.clip=function(t,r){if(t in o||(o[t]=function(t,r,e,o,i){var n=0,d=[];for(n;n<4;n++){var u=e[n].v,f=o[n].v,a=o[n].u||"px";d[n]=B(u,f,a,i)}t.style[r]="rect("+d+")"}),r instanceof Array)return[u(r[0]),u(r[1]),u(r[2]),u(r[3])];var e=r.replace(/rect|\(|\)/g,"");return e=/\,/g.test(e)?e.split(/\,/g):e.split(/\s/g),[u(e[0]),u(e[1]),u(e[2]),u(e[3])]},n.clip=function(t,r,e){var o=d(t,r),i=d(t,"width"),n=d(t,"height");return/rect/.test(o)?o:[0,i,n,0]},i.backgroundPosition=function(t,r){if(t in o||(o[t]=function(t,r,e,o,i){t.style[r]=B(e.x.v,o.x.v,"%",i)+" "+B(e.y.v,o.y.v,"%",i)}),r instanceof Array)return{x:u(r[0])||{v:50,u:"%"},y:u(r[1])||{v:50,u:"%"}};var e,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],e=u(n[0]),i=u(n[1]),{x:e,y:i}},n.backgroundPosition=function(t,r,e){return d(t,r)||C[r]},this});
|
2
dist/kute-svg.min.js
vendored
2
dist/kute-svg.min.js
vendored
File diff suppressed because one or more lines are too long
2
dist/kute.min.js
vendored
2
dist/kute.min.js
vendored
File diff suppressed because one or more lines are too long
52
kute-css.js
52
kute-css.js
|
@ -16,7 +16,8 @@
|
|||
})(this, function(KUTE){
|
||||
'use strict';
|
||||
|
||||
var g = typeof global !== 'undefined' ? global : window, K = KUTE, DOM = g.dom, parseProperty = K.pp, prepareStart = K.prS, getCurrentStyle = K.gCS, trueDimension = K.truD,
|
||||
var g = typeof global !== 'undefined' ? global : window, K = KUTE, DOM = g.dom, parseProperty = K.pp, prepareStart = K.prS,
|
||||
getCurrentStyle = K.gCS, trueDimension = K.truD, trueColor = K.truC,
|
||||
_br = K.property('borderRadius'), _brtl = K.property('borderTopLeftRadius'), _brtr = K.property('borderTopRightRadius'), // all radius props prefixed
|
||||
_brbl = K.property('borderBottomLeftRadius'), _brbr = K.property('borderBottomRightRadius'),
|
||||
_cls = ['borderColor', 'borderTopColor', 'borderRightColor', 'borderBottomColor', 'borderLeftColor', 'outlineColor'], // colors 'hex', 'rgb', 'rgba' -- #fff / rgb(0,0,0) / rgba(0,0,0,0)
|
||||
|
@ -26,52 +27,57 @@
|
|||
'borderWidth', 'borderTopWidth', 'borderRightWidth', 'borderBottomWidth', 'borderLeftWidth', 'outlineWidth'], // dimensions / box model
|
||||
_tp = ['fontSize','lineHeight','letterSpacing','wordSpacing'], // text properties
|
||||
_clp = ['clip'], _bg = ['backgroundPosition'], // clip | background position
|
||||
|
||||
_mg = _rd.concat(_bm,_tp), // a merge of all properties with px|%|em|rem|etc unit
|
||||
_all = _cls.concat(_clp, _rd, _bm, _tp, _bg), al = _all.length,
|
||||
number = g.Interpolate.number, unit = g.Interpolate.unit,
|
||||
number = g.Interpolate.number, unit = g.Interpolate.unit, color = g.Interpolate.color,
|
||||
_d = _d || {}; //all properties default values
|
||||
|
||||
//populate default values object
|
||||
for ( var i=0; i< al; i++ ){
|
||||
var p = _all[i];
|
||||
if (_cls.indexOf(p) !== -1){
|
||||
_d[p] = 'rgba(0,0,0,0)'; // _d[p] = {r:0,g:0,b:0,a:1};
|
||||
} else if ( _mg.indexOf(p) !== -1 ) {
|
||||
_d[p] = 0;
|
||||
} else if ( _bg.indexOf(p) !== -1 ){
|
||||
_d[p] = [50,50];
|
||||
} else if ( p === 'clip' ){
|
||||
_d[p] = [0,0,0,0];
|
||||
if (_cls.indexOf(_all[i]) !== -1){
|
||||
_d[_all[i]] = 'rgba(0,0,0,0)'; // _d[p] = {r:0,g:0,b:0,a:1};
|
||||
} else if ( _mg.indexOf(_all[i]) !== -1 ) {
|
||||
_d[_all[i]] = 0;
|
||||
} else if ( _bg.indexOf(_all[i]) !== -1 ){
|
||||
_d[_all[i]] = [50,50];
|
||||
} else if ( _all[i] === 'clip' ){
|
||||
_d[_all[i]] = [0,0,0,0];
|
||||
}
|
||||
}
|
||||
|
||||
// create prepare/process/render functions for additional colors properties
|
||||
for (var i = 0, l = _cls.length; i<l; i++) {
|
||||
p = _cls[i];
|
||||
parseProperty[p] = function(p,v) {
|
||||
return parseProperty.cls(p,v);
|
||||
parseProperty[_cls[i]] = 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 trueColor(v);
|
||||
};
|
||||
prepareStart[p] = function(el,p,v){
|
||||
prepareStart[_cls[i]] = function(el,p,v){
|
||||
return getCurrentStyle(el,p) || _d[p];
|
||||
};
|
||||
}
|
||||
|
||||
// create prepare/process/render functions for additional box model properties
|
||||
for (var i = 0, l = _mg.length; i<l; i++) {
|
||||
p = _mg[i];
|
||||
parseProperty[p] = function(p,v){
|
||||
return parseProperty.box(p,v);
|
||||
parseProperty[_mg[i]] = function(p,v){
|
||||
if (!(p in DOM)){
|
||||
DOM[p] = function(l,p,a,b,v){
|
||||
l.style[p] = unit(a.v,b.v,b.u,v);
|
||||
}
|
||||
}
|
||||
return trueDimension(v);
|
||||
};
|
||||
prepareStart[p] = function(el,p,v){
|
||||
prepareStart[_mg[i]] = function(el,p,v){
|
||||
return getCurrentStyle(el,p) || _d[p];
|
||||
};
|
||||
}
|
||||
|
||||
//create prepare/process/render functions for radius properties
|
||||
for (var i = 0, l = _rd.length; i<l; i++) {
|
||||
p = _rd[i];
|
||||
parseProperty[p] = function(p,v){
|
||||
parseProperty[_rd[i]] = function(p,v){
|
||||
if ( (!(p in DOM)) ) {
|
||||
if (p === 'borderRadius') {
|
||||
DOM[p] = function(l,p,a,b,v){
|
||||
|
@ -97,7 +103,7 @@
|
|||
}
|
||||
return trueDimension(v);
|
||||
};
|
||||
prepareStart[p] = function(el,p,v){
|
||||
prepareStart[_rd[i]] = function(el,p,v){
|
||||
return getCurrentStyle(el,p) || _d[p];
|
||||
};
|
||||
}
|
||||
|
|
33
kute-svg.js
33
kute-svg.js
|
@ -21,10 +21,11 @@
|
|||
// variables, reference global objects, prepare properties
|
||||
var g = typeof global !== 'undefined' ? global : window, K = KUTE, p, DOM = g.dom, parseProperty = K.pp, prepareStart = K.prS, getCurrentStyle = K.gCS,
|
||||
_isIE = navigator && (new RegExp("MSIE ([0-9]{1,}[\.0-9]{0,})").exec(navigator.userAgent) !== null) ? parseFloat( RegExp.$1 ) : false,
|
||||
trueColor = K.truC, trueDimension = K.truD,
|
||||
_nm = ['strokeWidth', 'strokeOpacity', 'fillOpacity', 'stopOpacity'], // numeric SVG CSS props
|
||||
_cls = ['fill', 'stroke', 'stopColor'], // colors 'hex', 'rgb', 'rgba' -- #fff / rgb(0,0,0) / rgba(0,0,0,0)
|
||||
pathReg = /(m[^(h|v|l)]*|[vhl][^(v|h|l|z)]*)/gmi, ns = 'http://www.w3.org/2000/svg',
|
||||
number = g.Interpolate.number, unit = g.Interpolate.unit, // interpolate functions
|
||||
number = g.Interpolate.number, unit = g.Interpolate.unit, color = g.Interpolate.color, // interpolate functions
|
||||
array = g.Interpolate.array = function array(a,b,l,v) { // array1, array2, array2.length, progress
|
||||
var na = [], i;
|
||||
for(i=0;i<l;i++) { na.push( a[i] === b[i] ? b[i] : number(a[i],b[i],v) ); } // don't do math if not needed
|
||||
|
@ -285,7 +286,7 @@
|
|||
return { s: start, e: end, l: l }
|
||||
};
|
||||
|
||||
parseProperty['draw'] = function(a,o,f){ // register the draw property
|
||||
parseProperty['draw'] = function(a,o,el){ // register the draw property
|
||||
if (!('draw' in DOM)) {
|
||||
DOM['draw'] = function(l,p,a,b,v){
|
||||
var ll = a.l, s = number(a.s,b.s,v), e = number(a.e,b.e,v), o = 0 - s;
|
||||
|
@ -293,7 +294,7 @@
|
|||
l.style.strokeDasharray = e+o<1 ? '0px, ' + ll + 'px' : (e+o) + 'px, ' + ll + 'px';
|
||||
}
|
||||
}
|
||||
return getDraw(f,o);
|
||||
return getDraw(el,o);
|
||||
}
|
||||
|
||||
prepareStart['draw'] = function(el,p,v){
|
||||
|
@ -303,30 +304,32 @@
|
|||
|
||||
// SVG CSS Color Properties
|
||||
for ( var i = 0, l = _cls.length; i< l; i++) {
|
||||
p = _cls[i];
|
||||
parseProperty[p] = function(p,v){
|
||||
return parseProperty.cls(p,v);
|
||||
parseProperty[_cls[i]] = 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 trueColor(v);
|
||||
}
|
||||
prepareStart[p] = function(el,p,v){
|
||||
prepareStart[_cls[i]] = function(el,p,v){
|
||||
return getCurrentStyle(el,p) || 'rgb(0,0,0)';
|
||||
}
|
||||
}
|
||||
|
||||
// Other SVG related CSS props
|
||||
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'){ // stroke can be unitless or unit | http://stackoverflow.com/questions/1301685/fixed-stroke-width-in-svg
|
||||
parseProperty[p] = function(p,v){
|
||||
if (_nm[i] === 'strokeWidth'){ // stroke can be unitless or unit | http://stackoverflow.com/questions/1301685/fixed-stroke-width-in-svg
|
||||
parseProperty[_nm[i]] = 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);
|
||||
l.style[p] = typeof b === 'number' ? number(a,b,v) : unit(a.v,b.v,b.u,v);
|
||||
}
|
||||
}
|
||||
return /px|%|em|vh|vw/.test(v) ? parseProperty.box(p,v) : parseFloat(v);
|
||||
return /px|%|em|vh|vw/.test(v) ? trueDimension(v) : parseFloat(v);
|
||||
}
|
||||
} else {
|
||||
parseProperty[p] = function(p,v){
|
||||
parseProperty[_nm[i]] = function(p,v){
|
||||
if (!(p in DOM)) {
|
||||
DOM[p] = function(l,p,a,b,v) {
|
||||
l.style[p] = number(a,b,v);
|
||||
|
@ -335,7 +338,7 @@
|
|||
return parseFloat(v);
|
||||
}
|
||||
}
|
||||
prepareStart[p] = function(el,p,v){
|
||||
prepareStart[_nm[i]] = function(el,p,v){
|
||||
return getCurrentStyle(el,p) || 0;
|
||||
}
|
||||
}
|
||||
|
|
102
kute.js
102
kute.js
|
@ -55,8 +55,9 @@
|
|||
} else if (/transparent|none|initial|inherit/.test(v)) {
|
||||
return { r: 0, g: 0, b: 0, a: 0 };
|
||||
} else if (!/^#|^rgb/.test(v) ) { // maybe we can check for web safe colors
|
||||
var h = document.getElementsByTagName('head')[0]; h.style.color = v; var webColor = g.getComputedStyle(h,null).color.replace(/[^\d,]/g, '').split(',');
|
||||
h.style.color = ''; return v !== webColor ? { r: parseInt(webColor[0]), g: parseInt(webColor[1]), b: parseInt(webColor[2]) } : {r:0,g:0,b:0};
|
||||
var h = document.getElementsByTagName('head')[0]; h.style.color = v;
|
||||
var webColor = g.getComputedStyle(h,null).color; webColor = /rgb/.test(webColor) ? webColor.replace(/[^\d,]/g, '').split(',') : [0,0,0];
|
||||
h.style.color = ''; return { r: parseInt(webColor[0]), g: parseInt(webColor[1]), b: parseInt(webColor[2]) };
|
||||
}
|
||||
},
|
||||
preventScroll = function (e) { // prevent mousewheel or touch events while tweening scroll
|
||||
|
@ -159,6 +160,7 @@
|
|||
} else if ( p === 'scale' || p === 'opacity' ){
|
||||
_d[p] = 1;
|
||||
}
|
||||
p = null;
|
||||
}
|
||||
|
||||
// KUTE.js INTERPOLATORS
|
||||
|
@ -213,7 +215,8 @@
|
|||
DOM = g.dom = {},
|
||||
ticker = g._ticker = function(t) {
|
||||
var i = 0, l;
|
||||
while ( i < (l=_tws.length) ) {
|
||||
// while ( i < (l=_tws.length) ) {
|
||||
while ( i < _tws.length ) {
|
||||
if ( update(_tws[i],t) ) {
|
||||
i++;
|
||||
} else {
|
||||
|
@ -235,7 +238,7 @@
|
|||
|
||||
if (elapsed === 1) {
|
||||
if (w._r > 0) {
|
||||
if ( w._r < 9999 ) { w._r--; } else { w._r = 9998; } // we have to make it stop somewhere, infinity is too damn much
|
||||
if ( w._r < 9999 ) { w._r--; } else { w._r = 0; } // we have to make it stop somewhere, infinity is too damn much
|
||||
|
||||
if (w._y) { w.reversed = !w.reversed; reverse.call(w); } // handle yoyo
|
||||
|
||||
|
@ -268,51 +271,47 @@
|
|||
},
|
||||
|
||||
// process properties for _vE and _vS or one of them
|
||||
preparePropertiesObject = function (e, s, l) {
|
||||
var pl = arguments.length, _st = []; pl = pl > 2 ? 2 : pl;
|
||||
|
||||
for (var i=0; i<pl; i++) {
|
||||
var t = arguments[i], x, sk = {}, rt = {}, tl = {}, tr = {}; _st[i] = {};
|
||||
for (x in t) {
|
||||
if (_tf.indexOf(x) !== -1) { // transform object gets built here
|
||||
if ( /^translate(?:[XYZ]|3d)$/.test(x) ) { //process translate3d
|
||||
var ta = ['X', 'Y', 'Z']; //coordinates // translate[x] = pp(x, t[x]);
|
||||
|
||||
for (var f = 0; f < 3; f++) {
|
||||
var a = ta[f];
|
||||
if ( /3d/.test(x) ) {
|
||||
tl['translate' + a] = parseProperty.transform('translate' + a, t[x][f]);
|
||||
} else {
|
||||
tl['translate' + a] = ('translate' + a in t) ? parseProperty.transform('translate' + a, t['translate' + a]) : { value: 0, unit: 'px' };
|
||||
}
|
||||
preparePropertiesObject = function (t, l) {
|
||||
var skewObject = {}, rotateObject = {}, translateObject = {}, transformObject = {}, propertiesObject = {};
|
||||
for (var x in t) {
|
||||
if (_tf.indexOf(x) !== -1) { // transform object gets built here
|
||||
if ( /^translate(?:[XYZ]|3d)$/.test(x) ) { //process translate3d
|
||||
var ta = ['X', 'Y', 'Z']; //coordinates // translate[x] = pp(x, t[x]);
|
||||
|
||||
for (var f = 0; f < 3; f++) {
|
||||
var a = ta[f];
|
||||
if ( /3d/.test(x) ) {
|
||||
translateObject['translate' + a] = parseProperty.transform('translate' + a, t[x][f]);
|
||||
} else {
|
||||
translateObject['translate' + a] = ('translate' + a in t) ? parseProperty.transform('translate' + a, t['translate' + a]) : { value: 0, unit: 'px' };
|
||||
}
|
||||
tr['translate'] = tl;
|
||||
} else if ( /^rotate(?:[XYZ])$|^skew(?:[XY])$/.test(x) ) { //process rotation/skew
|
||||
var ap = /rotate/.test(x) ? 'rotate' : 'skew', ra = ['X', 'Y', 'Z'],
|
||||
rtp = ap === 'rotate' ? rt : sk;
|
||||
for (var r = 0; r < 3; r++) {
|
||||
var v = ra[r];
|
||||
if ( t[ap+v] !== undefined && x !== 'skewZ' ) {
|
||||
rtp[ap+v] = parseProperty.transform(ap+v, t[ap+v]);
|
||||
}
|
||||
}
|
||||
tr[ap] = rtp;
|
||||
} else if ( /(rotate|translate|scale)$/.test(x) ) { //process 2d translation / rotation
|
||||
tr[x] = parseProperty.transform(x, t[x]);
|
||||
}
|
||||
_st[i]['transform'] = tr;
|
||||
} else if ( x !== 'transform') {
|
||||
if ( _bm.indexOf(x) !== -1 ) {
|
||||
_st[i][x] = parseProperty.box(x,t[x]);
|
||||
} else if (_op.indexOf(x) !== -1 || _sc.indexOf(x) !== -1) {
|
||||
_st[i][x] = parseProperty.unl(x,t[x]);
|
||||
} else if (_cls.indexOf(x) !== -1) {
|
||||
_st[i][x] = parseProperty.cls(x,t[x]);
|
||||
} else if (x in parseProperty) { _st[i][x] = parseProperty[x](x,t[x],l); } // or any other property from css/ attr / svg / third party plugins
|
||||
transformObject['translate'] = translateObject;
|
||||
} else if ( /^rotate(?:[XYZ])$|^skew(?:[XY])$/.test(x) ) { //process rotation/skew
|
||||
var ap = /rotate/.test(x) ? 'rotate' : 'skew', ra = ['X', 'Y', 'Z'],
|
||||
rtp = ap === 'rotate' ? rotateObject : skewObject;
|
||||
for (var r = 0; r < 3; r++) {
|
||||
var v = ra[r];
|
||||
if ( t[ap+v] !== undefined && x !== 'skewZ' ) {
|
||||
rtp[ap+v] = parseProperty.transform(ap+v, t[ap+v]);
|
||||
}
|
||||
}
|
||||
transformObject[ap] = rtp;
|
||||
} else if ( /(rotate|translate|scale)$/.test(x) ) { //process 2d translation / rotation
|
||||
transformObject[x] = parseProperty.transform(x, t[x]);
|
||||
}
|
||||
propertiesObject['transform'] = transformObject;
|
||||
} else if ( x !== 'transform') {
|
||||
if ( _bm.indexOf(x) !== -1 ) {
|
||||
propertiesObject[x] = parseProperty.box(x,t[x]);
|
||||
} else if (_op.indexOf(x) !== -1 || _sc.indexOf(x) !== -1) {
|
||||
propertiesObject[x] = parseProperty.unl(x,t[x]);
|
||||
} else if (_cls.indexOf(x) !== -1) {
|
||||
propertiesObject[x] = parseProperty.cls(x,t[x]);
|
||||
} else if (x in parseProperty) { propertiesObject[x] = parseProperty[x](x,t[x],l); } // or any other property from css/ attr / svg / third party plugins
|
||||
}
|
||||
}
|
||||
return _st;
|
||||
return propertiesObject;
|
||||
},
|
||||
|
||||
// process properties object | registers the plugins prepareStart functions
|
||||
|
@ -424,11 +423,10 @@
|
|||
}
|
||||
},
|
||||
close = function () { // when animation is finished reset repeat, yoyo&reversed tweens
|
||||
if (_tws.length-1 === _tws.indexOf(this)) { setTimeout(function(){stop()}, 48); } // when all animations are finished, stop ticking after ~3 frames
|
||||
// if (_tws.length === 0) { setTimeout(function(){stop()}, 48); } // when all animations are finished, stop ticking after ~3 frames
|
||||
if (this.repeat > 0) { this._r = this.repeat; }
|
||||
if (this._y && this.reversed===true) { reverse.call(this); this.reversed = false; }
|
||||
this.playing = false;
|
||||
setTimeout(function(){ if (!_tws.length) { stop(); } }, 48); // when all animations are finished, stop ticking after ~3 frames
|
||||
},
|
||||
scrollOut = function(){ //prevent scroll when tweening scroll
|
||||
if (( 'scroll' in this._vE || 'scrollTop' in this._vE ) && document.body.getAttribute('data-tweening')) {
|
||||
|
@ -531,7 +529,7 @@
|
|||
}
|
||||
|
||||
// now it's a good time to start
|
||||
_tws.push(this);
|
||||
add(this);
|
||||
this.playing = true;
|
||||
this.paused = false;
|
||||
this._sCF = false;
|
||||
|
@ -550,7 +548,7 @@
|
|||
this.paused = false;
|
||||
if (this._rC !== null) { this._rC.call(); }
|
||||
this._sT += time.now() - this._pST;
|
||||
_tws.push(this);
|
||||
add(this);
|
||||
!tick && ticker(); // restart ticking if stopped
|
||||
}
|
||||
return this;
|
||||
|
@ -664,7 +662,7 @@
|
|||
}
|
||||
|
||||
this._vS = {};
|
||||
this._vS = preparePropertiesObject(startValues,{},this._el)[0];
|
||||
this._vS = preparePropertiesObject(startValues,this._el);
|
||||
if ( 'transform' in this._vE ){ // stack transform
|
||||
var transform = 'transform';
|
||||
for ( var sp in this._vS['transform']) {
|
||||
|
@ -726,11 +724,11 @@
|
|||
// main methods
|
||||
to = function (el, to, o) {
|
||||
var _el = selector(el),
|
||||
_vS = to, _vE = preparePropertiesObject(to, {}, _el)[0]; o = o || {}; o.rpr = true;
|
||||
_vS = to, _vE = preparePropertiesObject(to,_el); o = o || {}; o.rpr = true;
|
||||
return new Tween(_el, _vS, _vE, o);
|
||||
},
|
||||
fromTo = function (el, f, to, o) {
|
||||
var _el = selector(el), ft = preparePropertiesObject(f, to, _el), _vS = ft[0], _vE = ft[1]; o = o || {};
|
||||
var _el = selector(el), _vS = preparePropertiesObject(f,_el), _vE = preparePropertiesObject(to,_el); o = o || {};
|
||||
var tw = new Tween(_el, _vS, _vE, o); K.svg && K.svq(tw); // on init we process the SVG paths
|
||||
return tw;
|
||||
},
|
||||
|
@ -747,7 +745,7 @@
|
|||
return K = { // export core methods to public for plugins
|
||||
property: property, getPrefix: getPrefix, selector: selector, pe : processEasing, // utils
|
||||
to: to, fromTo: fromTo, allTo: allTo, allFromTo: allFromTo, // main methods
|
||||
pp: parseProperty, prS: prepareStart, Tween : Tween, // property parsing & preparation | Tween
|
||||
pp: parseProperty, prS: prepareStart, //Tween : Tween, // property parsing & preparation | Tween
|
||||
truD: trueDimension, truC: trueColor, rth: rgbToHex, htr: hexToRGB, gCS: getCurrentStyle, // property parsing
|
||||
};
|
||||
}));
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "kute.js",
|
||||
"version": "1.5.95",
|
||||
"version": "1.5.96",
|
||||
"description": "A minimal Native Javascript animation engine.",
|
||||
"main": "kute.js",
|
||||
"scripts": {
|
||||
|
|
Loading…
Reference in a new issue