Small improvement, attribute tweening can also take into account current measurement unit if no unit is specified in end values.

This commit is contained in:
thednp 2016-09-20 06:45:11 +03:00
parent c6e7caabc6
commit d1e016185b
3 changed files with 7 additions and 7 deletions

View file

@ -52,9 +52,9 @@
var ats = {}, p;
for ( p in o ) {
var prop = replaceUppercase(p);
if ( /%|px/.test(o[p]) || /%|px/.test(getCurrentValue(l,prop.replace(/_+[a-z]+/,''))) ) {
var u = K.truD(o[p]).u, s = /%/.test(u) ? '_percent' : '_'+u; prop = prop.replace(s,'');
var prop = replaceUppercase(p), cv = getCurrentValue(l,prop.replace(/_+[a-z]+/,''));
if ( /%|[a-z]/.test(o[p]) || /%|[a-z]/.test(cv) ) {
var u = K.truD(cv).u || K.truD(o[p]).u, s = /%/.test(u) ? '_percent' : '_'+u; prop = prop.replace(s,'');
if (!(p+s in atts)) {
atts[p+s] = function(l,p,a,b,v) {
l.setAttribute(prop, unit(a.v,b.v,b.u,v) );

View file

@ -1,2 +1,2 @@
// Attributes Plugin for KUTE.js | dnp_theme | MIT License
(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,h=a.dom;c=a.pp;var l=a.Interpolate.unit,m=a.Interpolate.number,g,p=function(n,a){return n.getAttribute(a)},k=function(a){return/[A-Z]/g.test(a)?a.replace(a.match(/[A-Z]/g)[0],"-"+a.match(/[A-Z]/g)[0].toLowerCase()):a};a.prS.attr=function(a,d,c){d={};for(var b in c){c=k(b).replace(/_+[a-z]+/,"");var f=a.getAttribute(c);d[c]=f||(/opacity/i.test(b)?1:0)}return d};c.attr=function(c,d,q){"attr"in h||(h.attr=function(a,c,b,d,f){for(var e in d)h.attributes[e](a,e,b[e],d[e],f)},g=h.attributes={});c={};for(var b in d){var f=k(b);if(/%|px/.test(d[b])||/%|px/.test(p(q,f.replace(/_+[a-z]+/,"")))){var e=a.truD(d[b]).u,e=/%/.test(e)?"_percent":"_"+e,f=f.replace(e,"");b+e in g||(g[b+e]=function(a,c,b,d,e){a.setAttribute(f,l(b.v,d.v,d.u,e))});c[b+e]=a.truD(d[b])}else b in g||(g[b]=function(a,c,b,d,e){a.setAttribute(f,m(b,d,e))}),c[b]=parseFloat(d[b])}return c}});
(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,h=a.dom;c=a.pp;var l=a.Interpolate.unit,m=a.Interpolate.number,g,n=function(a,d){return a.getAttribute(d)},k=function(a){return/[A-Z]/g.test(a)?a.replace(a.match(/[A-Z]/g)[0],"-"+a.match(/[A-Z]/g)[0].toLowerCase()):a};a.prS.attr=function(a,d,c){d={};for(var b in c){c=k(b).replace(/_+[a-z]+/,"");var f=a.getAttribute(c);d[c]=f||(/opacity/i.test(b)?1:0)}return d};c.attr=function(c,d,p){"attr"in h||(h.attr=function(a,c,b,d,e){for(var f in d)h.attributes[f](a,f,b[f],d[f],e)},g=h.attributes={});c={};for(var b in d){var f=k(b),e=n(p,f.replace(/_+[a-z]+/,""));/%|[a-z]/.test(d[b])||/%|[a-z]/.test(e)?(e=a.truD(e).u||a.truD(d[b]).u,e=/%/.test(e)?"_percent":"_"+e,f=f.replace(e,""),b+e in g||(g[b+e]=function(a,c,b,d,e){a.setAttribute(f,l(b.v,d.v,d.u,e))}),c[b+e]=a.truD(d[b])):(b in g||(g[b]=function(a,c,b,d,e){a.setAttribute(f,m(b,d,e))}),c[b]=parseFloat(d[b]))}return c}});

View file

@ -52,9 +52,9 @@
var ats = {}, p;
for ( p in o ) {
var prop = replaceUppercase(p);
if ( /%|px/.test(o[p]) || /%|px/.test(getCurrentValue(l,prop.replace(/_+[a-z]+/,''))) ) {
var u = K.truD(o[p]).u, s = /%/.test(u) ? '_percent' : '_'+u; prop = prop.replace(s,'');
var prop = replaceUppercase(p), cv = getCurrentValue(l,prop.replace(/_+[a-z]+/,''));
if ( /%|[a-z]/.test(o[p]) || /%|[a-z]/.test(cv) ) {
var u = K.truD(cv).u || K.truD(o[p]).u, s = /%/.test(u) ? '_percent' : '_'+u; prop = prop.replace(s,'');
if (!(p+s in atts)) {
atts[p+s] = function(l,p,a,b,v) {
l.setAttribute(prop, unit(a.v,b.v,b.u,v) );