Minor fix/improvement with Attributes Plugin regarding current attribute value suffix.

This commit is contained in:
thednp 2016-09-20 23:32:11 +03:00
parent b83bb95a1e
commit cc332f0745
6 changed files with 10 additions and 8 deletions

View file

@ -36,6 +36,8 @@ For documentation, examples and other cool tips, check the <a href="http://thedn
# Attributes Plugin - [visit page](http://thednp.github.io/kute.js/attr.html)
* animates any numeric presentation attribute with suffixed value
* animates any other non-suffixed numeric presentation attribute
* handles attributes namespaces properly with `stroke-opacity` or `strokeOpacity`
* properly handles the suffixes for you
# Easing Functions - [visit page](http://thednp.github.io/kute.js/easing.html)
* optimized dynamics easing functions
@ -49,9 +51,9 @@ The plugin is just a few bits of code to bridge all of the the awesome `kute.js`
# NPM/Bower
You can install this through NPM or bower respectively:
```
$ npm install kute.js
# or
$ bower install kute.js
$ npm install kute.js
# or
$ bower install kute.js
```
# CommonJS/AMD support

View file

@ -1,6 +1,6 @@
{
"name": "KUTE.js",
"version": "1.5.5",
"version": "1.5.6",
"homepage": "http://thednp.github.io/kute.js",
"authors": [
"thednp"

View file

@ -53,7 +53,7 @@
var ats = {}, p;
for ( p in o ) {
var prop = replaceUppercase(p), cv = getCurrentValue(l,prop.replace(/_+[a-z]+/,''));
if ( /%|[a-z]/.test(o[p]) || /%|[a-z]/.test(cv) ) {
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;
if (!(p+s in atts)) {
atts[p+s] = function(l,p,a,b,v) {

View file

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

View file

@ -53,7 +53,7 @@
var ats = {}, p;
for ( p in o ) {
var prop = replaceUppercase(p), cv = getCurrentValue(l,prop.replace(/_+[a-z]+/,''));
if ( /%|[a-z]/.test(o[p]) || /%|[a-z]/.test(cv) ) {
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;
if (!(p+s in atts)) {
atts[p+s] = function(l,p,a,b,v) {

View file

@ -1,6 +1,6 @@
{
"name": "kute.js",
"version": "1.5.5",
"version": "1.5.6",
"description": "A minimal Native Javascript animation engine.",
"main": "kute.js",
"scripts": {