*/\r
public class Effects extends GQueryQueue {\r
\r
- public static int DEFAULT_SPEED = 400;\r
-\r
- public static Class<Effects> Effects = Effects.class;\r
-\r
- public static int FAST = 200;\r
-\r
- public static int SLOW = 600;\r
+ public static class Speed {\r
+ public static final int DEFAULT = 400;\r
+ public static final int SLOW = 600;\r
+ public static final int FAST = 200;\r
+ }\r
+ \r
+ public static final Class<Effects> Effects = Effects.class;\r
\r
static {\r
GQuery.registerPlugin(Effects.class, new Plugin<Effects>() {\r
*/\r
public Effects clip(ClipAnimation.Action a, ClipAnimation.Corner c,\r
ClipAnimation.Direction d, Function... f) {\r
- return clip(a, c, d, DEFAULT_SPEED, f);\r
+ return clip(a, c, d, Speed.DEFAULT, f);\r
}\r
\r
/**\r
*/\r
public Effects clip(ClipAnimation.Action a, ClipAnimation.Corner c,\r
Function... f) {\r
- return clip(a, c, Direction.BIDIRECTIONAL, DEFAULT_SPEED, f);\r
+ return clip(a, c, Direction.BIDIRECTIONAL, Speed.DEFAULT, f);\r
}\r
\r
/**\r
* The effect goes from the center to the perimeter.\r
*/\r
public Effects clipAppear(Function... f) {\r
- return clipAppear(DEFAULT_SPEED, f);\r
+ return clipAppear(Speed.DEFAULT, f);\r
}\r
\r
/**\r
* The effect goes from the perimeter to the center.\r
*/\r
public Effects clipDisappear(Function... f) {\r
- return clipDisappear(DEFAULT_SPEED, f);\r
+ return clipDisappear(Speed.DEFAULT, f);\r
}\r
\r
/**\r
* The effect goes from the top to the bottom.\r
*/\r
public Effects clipDown(Function... f) {\r
- return clipDown(DEFAULT_SPEED, f);\r
+ return clipDown(Speed.DEFAULT, f);\r
}\r
\r
/**\r
* The effect goes from the bottom to the top.\r
*/\r
public Effects clipUp(Function... f) {\r
- return clipUp(DEFAULT_SPEED, f);\r
+ return clipUp(Speed.DEFAULT, f);\r
}\r
\r
/**\r
* some form of height and width associated with them.\r
*/ \r
public Effects fadeIn(Function... f) {\r
- return fadeIn(DEFAULT_SPEED, f);\r
+ return fadeIn(Speed.DEFAULT, f);\r
}\r
\r
/**\r
* them.\r
*/ \r
public Effects fadeOut(Function... f) {\r
- return fadeOut(DEFAULT_SPEED, f);\r
+ return fadeOut(Speed.DEFAULT, f);\r
}\r
\r
/**\r
* optional callback after completion.\r
*/\r
public Effects slideDown(Function... f) {\r
- return slideDown(DEFAULT_SPEED, f);\r
+ return slideDown(Speed.DEFAULT, f);\r
}\r
\r
/**\r
* callback after completion.\r
*/\r
public Effects slideLeft(Function... f) {\r
- return slideLeft(DEFAULT_SPEED, f);\r
+ return slideLeft(Speed.DEFAULT, f);\r
}\r
\r
/**\r
* optional callback after completion.\r
*/\r
public Effects slideRight(Function... f) {\r
- return slideRight(DEFAULT_SPEED, f);\r
+ return slideRight(Speed.DEFAULT, f);\r
}\r
\r
/**\r
* callback after completion.\r
*/\r
public Effects slideUp(Function... f) {\r
- return slideUp(DEFAULT_SPEED, f);\r
+ return slideUp(Speed.DEFAULT, f);\r
}\r
\r
/**\r
*/\r
@Override\r
public Effects toggle() {\r
- return toggle(DEFAULT_SPEED);\r
+ return toggle(Speed.DEFAULT);\r
}\r
\r
/**\r
package gwtquery.samples.client;\r
\r
import static com.google.gwt.query.client.GQuery.$;\r
+import static com.google.gwt.query.client.plugins.Effects.Effects;\r
\r
import com.google.gwt.core.client.EntryPoint;\r
import com.google.gwt.core.client.GWT;\r
import com.google.gwt.query.client.GQuery;\r
import com.google.gwt.query.client.Selector;\r
import com.google.gwt.query.client.Selectors;\r
-import com.google.gwt.query.client.plugins.Effects;\r
+import com.google.gwt.query.client.plugins.Effects.Speed;\r
import com.google.gwt.user.client.Event;\r
\r
/**\r
final GQuery slides = $(s.allSlides());\r
\r
// we initially hide all slides and bullets\r
- slides.hide().eq(0).as(Effects.Effects).clipAppear();\r
+ slides.hide().eq(0).as(Effects).clipAppear();\r
$(s.allSlideBullets()).hide();\r
\r
\r
public boolean f(Event e) {\r
// onclick, if not all bullets shown, show a bullet and increment\r
if (curBullets < bullets.size()) {\r
- bullets.eq(curBullets++).show();\r
+ bullets.eq(curBullets++).as(Effects).fadeIn(Speed.SLOW);\r
} else {\r
// all bullets shown, hide them and current slide\r
bullets.hide();\r
+ \r
// move to next slide, checking for wrap around\r
- curSlide++;\r
+ int lastSlide = curSlide++;\r
if (curSlide == slides.size()) {\r
curSlide = 0;\r
}\r
- curBullets = 0;\r
+ \r
// query for new set of bullets, and show next slide\r
+ curBullets = 0;\r
bullets = $(s.slideBulletsCtx(slides.get(curSlide)));\r
- slides.eq(curSlide - 1).as(Effects.Effects).slideLeft(new Function() {\r
+ \r
+ // Hide the last slide and show the next when the effects finishes\r
+ slides.eq(lastSlide).as(Effects).fadeOut(new Function() {\r
public void f(Element e) {\r
- slides.eq(curSlide).as(Effects.Effects).clipAppear();\r
+ slides.eq(curSlide).as(Effects).clipAppear();\r
}\r
});\r
}\r