]> source.dussan.org Git - gwtquery.git/commitdiff
fix for issue 60 and 63
authorJulien Dramaix <julien.dramaix@gmail.com>
Tue, 18 Jan 2011 22:15:36 +0000 (22:15 +0000)
committerJulien Dramaix <julien.dramaix@gmail.com>
Tue, 18 Jan 2011 22:15:36 +0000 (22:15 +0000)
gwtquery-core/src/main/java/com/google/gwt/query/client/plugins/PropertiesAnimation.java

index 72154b2ec8f64e57836422be9ceb18a338a4ab90..fbb64dcf50ac96e1397363512e2077c06bfe5d08 100755 (executable)
@@ -15,8 +15,6 @@
  */\r
 package com.google.gwt.query.client.plugins;\r
 \r
-import java.util.ArrayList;\r
-\r
 import com.google.gwt.animation.client.Animation;\r
 import com.google.gwt.dom.client.Element;\r
 import com.google.gwt.query.client.Function;\r
@@ -26,6 +24,8 @@ import com.google.gwt.query.client.JSArray;
 import com.google.gwt.query.client.Properties;\r
 import com.google.gwt.query.client.Regexp;\r
 \r
+import java.util.ArrayList;\r
+\r
 /**\r
  *  Animation effects on any numeric CSS property. \r
  */\r
@@ -69,45 +69,59 @@ public class PropertiesAnimation extends Animation {
   }\r
   \r
   private static final String[] attrsToSave = new String[] { "overflow",\r
-      "visibility", "white-space" };\r
+      "visibility" };\r
 \r
   private static Regexp nonPxRegExp = new Regexp(\r
       "z-?index|font-?weight|opacity|zoom|line-?height", "i");\r
   \r
-  public static Effect computeFxProp(Element e, String key, String val, boolean hidden) {\r
+  \r
+  public static Effect computeFxProp(Element e, String key, String val,\r
+      boolean hidden) {\r
     GQuery g = Effects.$(e);\r
+    String unit = "";\r
     if ("toggle".equals(val)) {\r
       val = hidden ? "show" : "hide";\r
     }\r
+    \r
+    if (("show".equals(val) && !hidden) || ("hide").equals(val) && hidden){\r
+      return null;\r
+    }\r
+    \r
+    if (hidden){\r
+      g.show();\r
+    }\r
     double start = GQUtils.cur(e, key, true), end = start;\r
+    \r
     if ("show".equals(val)) {\r
-      if (!hidden) {\r
-        return null;\r
-      }\r
       g.saveCssAttrs(key);\r
       start = 0;\r
+      unit = nonPxRegExp.test(key) ? "" : "px";\r
     } else if ("hide".equals(val)) {\r
       if (hidden) {\r
         return null;\r
       }\r
       g.saveCssAttrs(key);\r
       end = 0;\r
-    } \r
-    JSArray parts = new Regexp("^([+-]=)?([0-9+-.]+)(.*)?$").match(val);\r
-    String unit = "";\r
-    if (parts != null) {\r
-      unit = nonPxRegExp.test(key) ? "" : parts.getStr(3) == null ? "px" : parts.getStr(3); \r
-      end = Double.parseDouble(parts.getStr(2));\r
-      if (!"px".equals(unit)) {\r
-        double to = end == 0 ? 1 : end;\r
-        g.css(key, to + unit);\r
-        start = to * start / GQUtils.cur(e, key, true);\r
-        g.css(key, start + unit);\r
-      }\r
-      if (parts.getStr(1) != null) {\r
-        end = (("-=".equals(parts.getStr(1)) ? -1 : 1) * end) + start;\r
+      unit = nonPxRegExp.test(key) ? "" : "px";\r
+    } else {\r
+      JSArray parts = new Regexp("^([+-]=)?([0-9+-.]+)(.*)?$").match(val);\r
+\r
+      if (parts != null) {\r
+        unit = nonPxRegExp.test(key) ? "" : parts.getStr(3) == null ? "px"\r
+            : parts.getStr(3);\r
+        end = Double.parseDouble(parts.getStr(2));\r
+        if (!"px".equals(unit)) {\r
+          double to = end == 0 ? 1 : end;\r
+          g.css(key, to + unit);\r
+          start = to * start / GQUtils.cur(e, key, true);\r
+          g.css(key, start + unit);\r
+        }\r
+        if (parts.getStr(1) != null) {\r
+          end = (("-=".equals(parts.getStr(1)) ? -1 : 1) * end) + start;\r
+        }\r
       }\r
-    } \r
+    }\r
+    \r
     Effect fx = new Effect(key, val, start, end, unit);\r
     return fx;\r
   }\r
@@ -144,7 +158,7 @@ public class PropertiesAnimation extends Animation {
       } else if ("show".equals(l.value)) {\r
         g.show();\r
         g.restoreCssAttrs(l.attr);\r
-      }\r
+      }     \r
     }\r
     g.restoreCssAttrs(attrsToSave);\r
     g.each(funcs);\r
@@ -157,7 +171,7 @@ public class PropertiesAnimation extends Animation {
     boolean move = false;\r
     boolean hidden = !g.visible();\r
     Effect fx;\r
-    g.show();\r
+    //g.show();\r
     for (String key : prps.keys()) {\r
       String val = prps.get(key);\r
       if ((fx = computeFxProp(e, key, val, hidden)) != null) {\r
@@ -169,7 +183,6 @@ public class PropertiesAnimation extends Animation {
     g.saveCssAttrs(attrsToSave);\r
     if (resize) {\r
       g.css("overflow", "hidden");\r
-      g.css("white-space", "nowrap");\r
     }\r
     if (move && !g.css("position", true).matches("absolute|relative")) {\r
       g.css("position", "relative");    \r