import com.google.gwt.query.client.plugins.effects.ClipAnimation.Action;
import com.google.gwt.query.client.plugins.effects.ClipAnimation.Direction;
import com.google.gwt.query.client.plugins.effects.Fx;
-import com.google.gwt.query.client.plugins.effects.PropertiesAnimation;
import com.google.gwt.query.client.plugins.effects.PropertiesAnimation.Easing;
import com.google.gwt.query.client.plugins.effects.PropertiesAnimation.EasingCurve;
-import com.google.gwt.query.client.plugins.effects.TransitionsAnimation;
import com.google.gwt.query.client.plugins.effects.TransitionsAnimation.TransitionsClipAnimation;
/**
public Effects animate(Object stringOrProperties, final int duration,
final Easing easing, final Function... funcs) {
-
final Properties p = (stringOrProperties instanceof String)
? $$((String) stringOrProperties) : (Properties) stringOrProperties;
for (Element e: elements()) {
if (Fx.css3) {
- new TransitionsAnimation(easing, e, p, funcs).run(duration);
+ new TransitionsClipAnimation(easing, e, p, funcs).run(duration);
} else {
- queueAnimation(e, new PropertiesAnimation(easing, e, p, funcs), duration);
+ queueAnimation(e, new ClipAnimation(easing, e, p, funcs), duration);
}
}
return this;
}
private static final String[] attrsToSave = new String[]{
- "position", "overflow", "visibility", "white-space", "top", "left", "width", "height"};
+ "position", "overflow", "visibility", "white-space", "top", "left", "width", "height"};
private Action action;
private Corner corner;
private Action currentAction;
public ClipAnimation(Element elem, Properties p, Function... funcs) {
- super(elem, p, funcs);
+ this(null, elem, p, funcs);
+ }
+
+ public ClipAnimation(Easing easing, Element elem, Properties p, Function... funcs) {
+ super(easing, elem, p, funcs);
corner = Corner.CENTER;
try {
corner = Corner.valueOf(getNormalizedValue("clip-origin", p));
g = GQuery.$(e).as(Effects.Effects);
}
- private static String getNormalizedValue(String value, Properties p) {
- return JsUtils.hyphenize(p.getStr("clip-direction")).replace("-", "_").toUpperCase();
+ public static String getNormalizedValue(String value, Properties p) {
+ return JsUtils.hyphenize(p.getStr(value)).replace("-", "_").toUpperCase();
}
public ClipAnimation(Element elem, Action a, Corner c, Direction d, Easing easing,
@Override
public void onComplete() {
super.onComplete();
+ if (action == null) {
+ return;
+ }
if (currentAction == Action.HIDE) {
g.hide();
}
public void onStart() {
boolean hidden = !g.isVisible();
super.onStart();
+ if (action == null) {
+ return;
+ }
currentAction = action != Action.TOGGLE ? action : hidden ? Action.SHOW : Action.HIDE;
g.saveCssAttrs(attrsToSave);
@Override
public void onUpdate(double progress) {
super.onUpdate(progress);
+ if (action == null) {
+ return;
+ }
if (currentAction == Action.HIDE) {
progress = (1 - progress);
}
*/
package com.google.gwt.query.client.plugins.effects;
-import static com.google.gwt.query.client.GQuery.*;
+import static com.google.gwt.query.client.GQuery.$;
+import static com.google.gwt.query.client.GQuery.$$;
+import static com.google.gwt.query.client.plugins.effects.ClipAnimation.getNormalizedValue;
import com.google.gwt.dom.client.Element;
import com.google.gwt.query.client.Function;
private Direction direction;
private Action currentAction;
+ public TransitionsClipAnimation(Element elem, Properties p, Function... funcs) {
+ this(null, elem, p, funcs);
+ }
+
+ public TransitionsClipAnimation(Easing easing, Element elem, Properties p, Function... funcs) {
+ super(easing, elem, p, funcs);
+ corner = Corner.CENTER;
+ try {
+ corner = Corner.valueOf(getNormalizedValue("clip-origin", p));
+ } catch (Exception e) {
+ }
+ direction = Direction.BIDIRECTIONAL;
+ try {
+ direction = Direction.valueOf(getNormalizedValue("clip-direction", p));
+ } catch (Exception e) {
+ }
+ try {
+ action = Action.valueOf(getNormalizedValue("clip-action", p));
+ } catch (Exception e) {
+ }
+ }
+
public TransitionsClipAnimation(Element elem, Action a, Corner c, Direction d, Easing easing,
Properties p, final Function... funcs) {
super(easing, elem, p, funcs);
boolean hidden = !g.isVisible();
super.onStart();
-
+ if (action == null) {
+ return;
+ }
currentAction = action != Action.TOGGLE ? action : hidden ? Action.SHOW : Action.HIDE;
int bit = currentAction == Action.HIDE ? 1 : 0;
@Override
public void onComplete() {
super.onComplete();
+ if (action == null) {
+ return;
+ }
if (currentAction == Action.HIDE) {
g.hide();
}