*/\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
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
}\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
} 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
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
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