public enum Speed {\r
\r
/**\r
- * 600 millisecond animation.\r
+ * 400 millisecond animation.\r
*/\r
- SLOW(600),\r
+ DEFAULT(400),\r
/**\r
* 200 millisecond animation.\r
*/\r
FAST(200),\r
/**\r
- * 400 millisecond animation.\r
+ * 600 millisecond animation.\r
*/\r
- DEFAULT(400);\r
+ SLOW(600);\r
\r
private final int duration;\r
\r
*/\r
protected class PropFx {\r
\r
- public SpeedOpts opt;\r
-\r
public Element elem;\r
\r
- public String prop;\r
-\r
- private double startTime;\r
+ public SpeedOpts opt;\r
\r
- private double start;\r
+ public String prop;\r
\r
private double end;\r
\r
- private String unit;\r
-\r
private double now;\r
\r
private double pos;\r
\r
+ private double start;\r
+\r
+ private double startTime;\r
+\r
private double state;\r
\r
+ private String unit;\r
+\r
public double cur(boolean force) {\r
if (elem.getPropertyString(prop) != null && (elem.getStyle() == null\r
|| elem.getStyle().getProperty(prop) == null)) {\r
return animate(genFx("hide", 3), speed, Easing.LINEAR, callback);\r
}\r
\r
+ public void show() {\r
+ opt.cache.put(prop, elem.getStyle().getProperty(prop));\r
+ opt.show = true;\r
+ custom("width".equals(prop) || "height".equals(prop) ? 1 : 0, cur(false));\r
+ $(elem).show();\r
+ }\r
+\r
public Effects show(Speed speed) {\r
return show(speed, null);\r
}\r
return animate(genFx("show", 3), speed, Easing.LINEAR, callback);\r
}\r
\r
- public void show() {\r
- opt.cache.put(prop, elem.getStyle().getProperty(prop));\r
- opt.show = true;\r
- custom("width".equals(prop) || "height".equals(prop) ? 1 : 0, cur(false));\r
- $(elem).show();\r
- }\r
-\r
public Effects toggle(Speed speed) {\r
return hide(speed, null);\r
}\r
\r
private class SpeedOpts {\r
\r
- public String display;\r
-\r
- public String overflow;\r
-\r
public Properties curAnim;\r
\r
+ public String display;\r
+\r
public boolean hide;\r
\r
+ public String overflow;\r
+\r
public boolean show;\r
\r
- private Properties properties;\r
+ private GQuery.DataCache cache = DataCache.createObject().cast();\r
+\r
+ private Function complete;\r
\r
private int duration;\r
\r
private Effects.Easing easing;\r
\r
- private Function complete;\r
+ private Properties properties;\r
\r
private boolean queue = true;\r
\r
- private GQuery.DataCache cache = DataCache.createObject().cast();\r
-\r
protected SpeedOpts(int speed, Easing easing, Function complete) {\r
this.complete = complete;\r
this.easing = easing;\r
super(list);\r
}\r
\r
- public Effects animate(final Properties properties, final Speed speed,\r
- final Easing easing, final Function complete) {\r
- return animate(properties, speed.getDuration(), easing, complete);\r
- }\r
-\r
public Effects animate(final Properties properties, final int speed,\r
final Easing easing, final Function complete) {\r
if (!"false".equals(properties.get("queue"))) {\r
return this;\r
}\r
\r
+\r
+ public Effects animate(final Properties properties, final Speed speed,\r
+ final Easing easing, final Function complete) {\r
+ return animate(properties, speed.getDuration(), easing, complete);\r
+ }\r
+ \r
/**\r
- * Fade in all matched elements by adjusting their opacity. Only the opacity\r
- * is adjusted for this animation, meaning that all of the matched elements\r
- * should already have some form of height and width associated with them.\r
+ * Removes a queued function from the front of the FX queue and executes it.\r
*/\r
- public Effects fadeIn() {\r
- return fadeIn(Speed.DEFAULT);\r
+ public Effects dequeue() {\r
+ return (Effects)dequeue("__FX");\r
}\r
\r
/**\r
* is adjusted for this animation, meaning that all of the matched elements\r
* should already have some form of height and width associated with them.\r
*/\r
- public Effects fadeIn(Speed speed) {\r
- return fadeIn(speed, null);\r
+ public Effects fadeIn() {\r
+ return fadeIn(Speed.DEFAULT);\r
}\r
\r
/**\r
* animation, meaning that all of the matched elements should already have\r
* some form of height and width associated with them.\r
*/\r
- public Effects fadeIn(Speed speed, Function callback) {\r
- return fadeIn(speed.duration, callback);\r
+ public Effects fadeIn(int speed, Function callback) {\r
+ return animate($$("opacity: \"show\""), speed, Easing.LINEAR, callback);\r
+ }\r
+\r
+ /**\r
+ * Fade in all matched elements by adjusting their opacity. Only the opacity\r
+ * is adjusted for this animation, meaning that all of the matched elements\r
+ * should already have some form of height and width associated with them.\r
+ */\r
+ public Effects fadeIn(Speed speed) {\r
+ return fadeIn(speed, null);\r
}\r
\r
/**\r
* animation, meaning that all of the matched elements should already have\r
* some form of height and width associated with them.\r
*/\r
- public Effects fadeIn(int speed, Function callback) {\r
- return animate($$("opacity: \"show\""), speed, Easing.LINEAR, callback);\r
+ public Effects fadeIn(Speed speed, Function callback) {\r
+ return fadeIn(speed.duration, callback);\r
}\r
\r
/**\r
* that all of the matched elements should already have some form of height\r
* and width associated with them.\r
*/\r
- public Effects fadeOut(Speed speed) {\r
+ public Effects fadeOut(int speed) {\r
return fadeOut(speed, null);\r
}\r
\r
+ /**\r
+ * Fade out all matched elements by adjusting their opacity to 0, then setting\r
+ * display to "none" and firing an optional callback after completion. Only\r
+ * the opacity is adjusted for this animation, meaning that all of the matched\r
+ * elements should already have some form of height and width associated with\r
+ * them.\r
+ */\r
+ public Effects fadeOut(int speed, Function callback) {\r
+ return animate($$("opacity: \"hide\""), speed, Easing.LINEAR, callback);\r
+ }\r
+\r
/**\r
* Fade out all matched elements by adjusting their opacity to 0, then setting\r
* display to "none". Only the opacity is adjusted for this animation, meaning\r
* that all of the matched elements should already have some form of height\r
* and width associated with them.\r
*/\r
- public Effects fadeOut(int speed) {\r
+ public Effects fadeOut(Speed speed) {\r
return fadeOut(speed, null);\r
}\r
\r
return fadeOut(speed.duration, callback);\r
}\r
\r
- /**\r
- * Fade out all matched elements by adjusting their opacity to 0, then setting\r
- * display to "none" and firing an optional callback after completion. Only\r
- * the opacity is adjusted for this animation, meaning that all of the matched\r
- * elements should already have some form of height and width associated with\r
- * them.\r
- */\r
- public Effects fadeOut(int speed, Function callback) {\r
- return animate($$("opacity: \"hide\""), speed, Easing.LINEAR, callback);\r
- }\r
-\r
/**\r
* Fade the opacity of all matched elements to a specified opacity. Only the\r
* opacity is adjusted for this animation, meaning that all of the matched\r
return this;\r
}\r
\r
+ /**\r
+ * Adds a new function, to be executed, onto the end of the queue of all\r
+ * matched elements in the FX queue.\r
+ */\r
+ public GQueryQueue queue(Function data) {\r
+ return queue("__FX", data);\r
+ }\r
+\r
/**\r
* Displays each of the set of matched elements if they are hidden.\r
*/\r