public static final Class<Effects> Effects = Effects.class;\r
\r
private static final String EFFECTS_RUNNNING = "EffectsRunnning";\r
- \r
+\r
static {\r
GQuery.registerPlugin(Effects.class, new Plugin<Effects>() {\r
public Effects init(GQuery gq) {\r
anim.cancel();\r
}\r
}\r
+\r
public void f(Element e) {\r
Animation anim = new PropertiesAnimation(easing, e, p, funcs);\r
anim.run(duration);\r
});\r
return this;\r
}\r
- \r
+\r
/**\r
* The animate() method allows us to create animation effects on any numeric CSS property. \r
* The only required parameter is a map of CSS properties. \r
ClipAnimation.Direction d, Function... f) {\r
return clip(a, c, d, Speed.DEFAULT, f);\r
}\r
- \r
+\r
/**\r
- * Animate the set of matched elements using the clip property.\r
- * It is possible to show or hide a set of elements, \r
- * specify the direction of the animation and the start corner of the effect.\r
- * Finally it executes the set of functions passed as arguments.\r
+ * Animate the set of matched elements using the clip property. It is possible\r
+ * to show or hide a set of elements, specify the direction of the animation\r
+ * and the start corner of the effect. Finally it executes the set of\r
+ * functions passed as arguments.\r
*/\r
public Effects clip(final ClipAnimation.Action a, final ClipAnimation.Corner c, \r
final ClipAnimation.Direction d, final int duration, final Function... f) {\r
anim.cancel();\r
}\r
}\r
+\r
public void f(Element e) {\r
Animation anim = new ClipAnimation(e, a, c, d, f);\r
anim.run(duration);\r
data(e, EFFECTS_RUNNNING, a);\r
}\r
- }); \r
+ });\r
return this;\r
}\r
\r
public Effects clipAppear(Function... f) {\r
return clipAppear(Speed.DEFAULT, f);\r
}\r
- \r
+\r
/**\r
* Reveal all matched elements by adjusting the clip property firing an\r
* optional callback after completion.\r
public Effects clipDisappear(Function... f) {\r
return clipDisappear(Speed.DEFAULT, f);\r
}\r
- \r
+\r
/**\r
* Hide all matched elements by adjusting the clip property firing an\r
* optional callback after completion.\r
return clip(Action.SHOW, ClipAnimation.Corner.TOP_LEFT,\r
ClipAnimation.Direction.BIDIRECTIONAL, millisecs, f);\r
}\r
- \r
+\r
/**\r
* Toggle the visibility of all matched elements by adjusting the clip property\r
* and firing an optional callback after completion.\r
ClipAnimation.Direction.VERTICAL, millisecs, f);\r
}\r
\r
-\r
/**\r
* Hide all matched elements by adjusting the clip property firing an\r
* optional callback after completion.\r
public Effects fadeTo(int millisecs, double opacity, Function... f) {\r
return animate("opacity: " + opacity, millisecs, f);\r
}\r
- \r
+\r
+ /**\r
+ * Display or hide the matched elements by animating their opacity. and firing\r
+ * an optional callback after completion. Only the opacity is adjusted for\r
+ * this animation, meaning that all of the matched elements should already\r
+ * have some form of height and width associated with them.\r
+ */\r
+ public Effects fadeToggle(Function... f) {\r
+ return fadeToggle(Speed.DEFAULT, f);\r
+ }\r
+\r
+ /**\r
+ * Display or hide the matched elements by animating their opacity. and firing\r
+ * an optional callback after completion. Only the opacity is adjusted for\r
+ * this animation, meaning that all of the matched elements should already\r
+ * have some form of height and width associated with them.\r
+ */\r
+ public Effects fadeToggle(int millisecs, Function... f) {\r
+ return animate("opacity: 'toggle'", millisecs, f);\r
+ };\r
+\r
/**\r
* Reveal all matched elements by adjusting their height and firing an\r
* optional callback after completion.\r
* firing an optional callback after completion. Only the height is adjusted\r
* for this animation, causing all matched elements to be hidden or shown in a\r
* "sliding" manner\r
- */ \r
+ */\r
public Effects slideToggle(int millisecs, Function... f) {\r
return animate("height: 'toggle'", millisecs, f);\r
}\r
/**\r
* Toggle displaying each of the set of matched elements.\r
*/\r
- @Override\r
- public Effects toggle() {\r
- return toggle(Speed.DEFAULT);\r
- }\r
+ /*\r
+ * -> already implemented in GQuery and this is the good one\r
+ * \r
+ * @Override public Effects toggle() { return toogle(Speed.DEFAULT); }\r
+ */\r
\r
/**\r
* Toggle displaying each of the set of matched elements.\r
+ * \r
+ * @param showOrHide A Boolean indicating whether to show or hide the\r
+ * elements.\r
+ */\r
+ // maybe move this function in GQuery class directly ?\r
+ public Effects toggle(boolean showOrHide) {\r
+ for (Element element : elements()) {\r
+ GQuery $element = $(element);\r
+ if (!showOrHide) {\r
+ $element.hide();\r
+ } else {\r
+ $element.show();\r
+ }\r
+\r
+ }\r
+ return this;\r
+ }\r
+\r
+ /**\r
+ * Toggle displaying each of the set of matched elements by animating the\r
+ * width, height, and opacity of the matched elements simultaneously. When\r
+ * these properties reach 0 after a hiding animation, the display style\r
+ * property is set to none to ensure that the element no longer affects the\r
+ * layout of the page.\r
*/\r
public Effects toggle(int millisecs, Function... f) {\r
- return animate("opacity: 'toggle'", millisecs, f);\r
+ return animate("opacity: 'toggle', width : 'toggle', height : 'toggle'",\r
+ millisecs, f);\r
}\r
}\r
*/
package com.google.gwt.query.client.plugins;
import com.google.gwt.animation.client.Animation;
+import com.google.gwt.core.client.GWT;
import com.google.gwt.dom.client.Element;
import com.google.gwt.dom.client.NodeList;
import com.google.gwt.query.client.Function;
*/
LazyEffects<T> fadeTo(int millisecs, double opacity, Function... f);
+ /**
+ * Display or hide the matched elements by animating their opacity. and firing
+ * an optional callback after completion. Only the opacity is adjusted for
+ * this animation, meaning that all of the matched elements should already
+ * have some form of height and width associated with them.
+ */
+ LazyEffects<T> fadeToggle(Function... f);
+
+ /**
+ * Display or hide the matched elements by animating their opacity. and firing
+ * an optional callback after completion. Only the opacity is adjusted for
+ * this animation, meaning that all of the matched elements should already
+ * have some form of height and width associated with them.
+ */
+ LazyEffects<T> fadeToggle(int millisecs, Function... f);
+
/**
* Reveal all matched elements by adjusting their height and firing an
* optional callback after completion.
/**
* Toggle displaying each of the set of matched elements.
+ *
+ * @param showOrHide
+ * A Boolean indicating whether to show or hide the elements.
*/
- LazyEffects<T> toggle();
+ LazyEffects<T> toggle(boolean showOrHide);
/**
- * Toggle displaying each of the set of matched elements.
+ * Toggle displaying each of the set of matched elements by animating the
+ * width, height, and opacity of the matched elements simultaneously. When
+ * these properties reach 0 after a hiding animation, the display style
+ * property is set to none to ensure that the element no longer affects the
+ * layout of the page.
*/
LazyEffects<T> toggle(int millisecs, Function... f);