From 1c0942cb42c229025290b35a6b8ba53b6c172abd Mon Sep 17 00:00:00 2001 From: Julian Garnier Date: Tue, 28 Jun 2016 21:01:09 +0200 Subject: [PATCH] fix #11 --- anime.js | 8 ++++++-- anime.min.js | 12 ++++++------ 2 files changed, 12 insertions(+), 8 deletions(-) diff --git a/anime.js b/anime.js index ecc2e8c2..f9f0ec69 100644 --- a/anime.js +++ b/anime.js @@ -234,12 +234,16 @@ var getAnimationType = function(el, prop) { if ((is.node(el) || is.svg(el)) && arrayContains(validTransforms, prop)) return 'transform'; if ((is.node(el) || is.svg(el)) && (prop !== 'transform' && getCSSValue(el, prop))) return 'css'; - if ((is.node(el) || is.svg(el)) && (el.getAttribute(prop) || el[prop])) return 'attribute'; + if ((is.node(el) || is.svg(el)) && (el.getAttribute(prop) || (is.svg(el) && el[prop]))) return 'attribute'; if (!is.null(el[prop]) && !is.undef(el[prop])) return 'object'; } var getCSSValue = function(el, prop) { - return getComputedStyle(el).getPropertyValue(stringToHyphens(prop)); + // First check if prop is a valid CSS property + if (prop in el.style) { + // Then return the property value or fallback to '0' when getPropertyValue fails + return getComputedStyle(el).getPropertyValue(stringToHyphens(prop)) || '0'; + } } var getTransformValue = function(el, prop) { diff --git a/anime.min.js b/anime.min.js index 68290eed..69983a12 100644 --- a/anime.min.js +++ b/anime.min.js @@ -13,12 +13,12 @@ Bounce:function(a){for(var b,f=4;a<((b=Math.pow(2,--f))-1)/11;);return 1/Math.po "$1-$2").toLowerCase()},B=function(a){if(e.color(a))return!1;try{return document.querySelectorAll(a)}catch(b){return!1}},v=function(a){return a.reduce(function(a,c){return a.concat(e.array(c)?v(c):c)},[])},p=function(a){if(e.array(a))return a;e.string(a)&&(a=B(a)||a);return e.html(a)?[].slice.call(a):[a]},C=function(a,b){return a.some(function(a){return a===b})},N=function(a,b){var c={};a.forEach(function(a){var f=JSON.stringify(b.map(function(b){return a[b]}));c[f]=c[f]||[];c[f].push(a)});return Object.keys(c).map(function(a){return c[a]})}, D=function(a){return a.filter(function(a,c,d){return d.indexOf(a)===c})},w=function(a){var b={},c;for(c in a)b[c]=a[c];return b},t=function(a,b){for(var c in b)a[c]=e.undef(a[c])?b[c]:a[c];return a},O=function(a){a=a.replace(/^#?([a-f\d])([a-f\d])([a-f\d])$/i,function(a,b,c,e){return b+b+c+c+e+e});var b=/^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(a);a=parseInt(b[1],16);var c=parseInt(b[2],16),b=parseInt(b[3],16);return"rgb("+a+","+c+","+b+")"},P=function(a){a=/hsl\((\d+),\s*([\d.]+)%,\s*([\d.]+)%\)/g.exec(a); var b=parseInt(a[1])/360,c=parseInt(a[2])/100,d=parseInt(a[3])/100;a=function(a,b,c){0>c&&(c+=1);1c?b:c<2/3?a+(b-a)*(2/3-c)*6:a};if(0==c)c=d=b=d;else var f=.5>d?d*(1+c):d+c-d*c,h=2*d-f,c=a(h,f,b+1/3),d=a(h,f,b),b=a(h,f,b-1/3);return"rgb("+255*c+","+255*d+","+255*b+")"},k=function(a){return/([\+\-]?[0-9|auto\.]+)(%|px|pt|em|rem|in|cm|mm|ex|pc|vw|vh|deg)?/.exec(a)[2]},E=function(a,b,c){return k(b)?b:-1=a.delay&&(a.begin(b),a.begin=void 0);c.current>=b.duration?(a.loop?(c.start=+new Date,"alternate"===a.direction&&y(b,!0),e.number(a.loop)&&