]> source.dussan.org Git - gwtquery.git/commitdiff
CSS3 animations where failing with "%" units, fixing it in the same way we do with...
authorManuel Carrasco Moñino <manuel.carrasco.m@gmail.com>
Tue, 10 Dec 2013 08:48:12 +0000 (09:48 +0100)
committerManuel Carrasco Moñino <manuel.carrasco.m@gmail.com>
Tue, 10 Dec 2013 08:48:12 +0000 (09:48 +0100)
gwtquery-core/src/main/java/com/google/gwt/query/client/plugins/effects/TransitionsAnimation.java

index 0bb7e1e3e90597de3d31a5c5ed74d485bbef2f91..c93e62bf59d8b033b152a5313ea2d5c9cae0ee5c 100755 (executable)
@@ -148,16 +148,14 @@ public class TransitionsAnimation extends PropertiesAnimation {
     } else {
       MatchResult parts = REGEX_SYMBOL_NUMBER_UNIT.exec(val);
       if (parts != null) {
-        unit = REGEX_NON_PIXEL_ATTRS.test(key) || Transitions.transformRegex.test(key) ? "" : "px";
 
         String part1 = parts.getGroup(1);
         String part2 = parts.getGroup(2);
         String part3 = parts.getGroup(3);
         trsEnd = "" + Double.parseDouble(part2);
 
-        if (unit.isEmpty() && part3 != null) {
-          unit = part3;
-        }
+        unit = REGEX_NON_PIXEL_ATTRS.test(key) ? "" :  part3 == null || part3.isEmpty() ? "px" : part3;
+
         if (trsStart.isEmpty()) {
           trsStart = key.matches("scale") ? "1" : "0";
         }
@@ -168,6 +166,17 @@ public class TransitionsAnimation extends PropertiesAnimation {
           double en = Double.parseDouble(trsEnd);
           trsEnd = "" + (st + (n*en));
         }
+
+        // Deal with non px units like "%"
+        if (!unit.isEmpty() && !"px".equals(unit) && trsStart.matches("\\d+")) {
+          double start = Double.parseDouble(trsStart);
+          double to = Double.parseDouble(trsEnd);
+          g.css(key, to + unit);
+          start = to * start / g.cur(key, true);
+          trsStart = start + unit;
+          g.css(key, start + unit);
+        }
+
       } else {
         trsStart = "";
         trsEnd = val;