}
public static Fx computeFxNumericProp(Element e, String key, String val,
boolean hidden) {
GQuery g = Effects.$(e);
String unit = "";
if ("toggle".equals(val)) {
val = hidden ? "show" : "hide";
}
if (("show".equals(val) && !hidden) || ("hide").equals(val) && hidden) {
return null;
}
if (hidden) {
g.show();
}
// If key starts with $ we animate node attributes, otherwise css properties
double cur;
String rkey = null;
if (key.startsWith("$")) {
rkey = key.substring(1).toLowerCase();
String attr = g.attr(rkey);
MatchResult parts = REGEX_NUMBER_UNIT.exec(attr);
if (parts != null) {
String $1 = parts.getGroup(1);
String $2 = parts.getGroup(2);
cur = Double.parseDouble($1);
unit = $2 == null ? "" : $2;
} else {
cur = g.cur(key, true);
key = rkey;
}
} else {
cur = g.cur(key, true);
}
double start = cur, end = start;
if ("show".equals(val)) {
g.saveCssAttrs(key);
start = 0;
unit = REGEX_NON_PIXEL_ATTRS.test(key) ? "" : "px";
} else if ("hide".equals(val)) {
if (hidden) {
return null;
}
g.saveCssAttrs(key);
end = 0;
unit = REGEX_NON_PIXEL_ATTRS.test(key) ? "" : "px";
} else {
MatchResult parts = REGEX_SYMBOL_NUMBER_UNIT.exec(val);
if (parts != null) {
String $1 = parts.getGroup(1);
String $2 = parts.getGroup(2);
String $3 = parts.getGroup(3);
end = Double.parseDouble($2);
if (rkey == null) {
unit = REGEX_NON_PIXEL_ATTRS.test(key) ? "" : //
$3 == null || $3.isEmpty() ? "px" : $3;
if (!"px".equals(unit)) {
double to = end == 0 ? 1 : end;
g.css(key, to + unit);
start = to * start / g.cur(key, true);
g.css(key, start + unit);
}
} else if ($3 != null && !$3.isEmpty()) {
unit = $3;
}