From bd4e166120484ee615611bf542a590e335cbf81d Mon Sep 17 00:00:00 2001 From: Manolo Carrasco Date: Fri, 11 Jun 2010 22:58:43 +0000 Subject: [PATCH] fixed a silly issue in the demo module --- .../com/google/gwt/query/client/GQuery.java | 1 - .../gwt/query/client/plugins/Effects.java | 40 +++++++++---------- .../samples/client/GwtQueryDemoModule.java | 19 +++++---- 3 files changed, 32 insertions(+), 28 deletions(-) diff --git a/gwtquery-core/src/main/java/com/google/gwt/query/client/GQuery.java b/gwtquery-core/src/main/java/com/google/gwt/query/client/GQuery.java index 8f3113ac..efeda8c5 100644 --- a/gwtquery-core/src/main/java/com/google/gwt/query/client/GQuery.java +++ b/gwtquery-core/src/main/java/com/google/gwt/query/client/GQuery.java @@ -32,7 +32,6 @@ import com.google.gwt.dom.client.Node; import com.google.gwt.dom.client.NodeList; import com.google.gwt.dom.client.OptionElement; import com.google.gwt.dom.client.SelectElement; -import com.google.gwt.dom.client.Style; import com.google.gwt.dom.client.TextAreaElement; import com.google.gwt.dom.client.Style.Display; import com.google.gwt.query.client.css.CssProperty; diff --git a/gwtquery-core/src/main/java/com/google/gwt/query/client/plugins/Effects.java b/gwtquery-core/src/main/java/com/google/gwt/query/client/plugins/Effects.java index d1b12fd9..8ba38829 100755 --- a/gwtquery-core/src/main/java/com/google/gwt/query/client/plugins/Effects.java +++ b/gwtquery-core/src/main/java/com/google/gwt/query/client/plugins/Effects.java @@ -31,13 +31,13 @@ import com.google.gwt.query.client.plugins.PropertiesAnimation.Easing; */ public class Effects extends GQueryQueue { - public static int DEFAULT_SPEED = 400; - - public static Class Effects = Effects.class; - - public static int FAST = 200; - - public static int SLOW = 600; + public static class Speed { + public static final int DEFAULT = 400; + public static final int SLOW = 600; + public static final int FAST = 200; + } + + public static final Class Effects = Effects.class; static { GQuery.registerPlugin(Effects.class, new Plugin() { @@ -137,7 +137,7 @@ public class Effects extends GQueryQueue { */ public Effects clip(ClipAnimation.Action a, ClipAnimation.Corner c, ClipAnimation.Direction d, Function... f) { - return clip(a, c, d, DEFAULT_SPEED, f); + return clip(a, c, d, Speed.DEFAULT, f); } /** @@ -164,7 +164,7 @@ public class Effects extends GQueryQueue { */ public Effects clip(ClipAnimation.Action a, ClipAnimation.Corner c, Function... f) { - return clip(a, c, Direction.BIDIRECTIONAL, DEFAULT_SPEED, f); + return clip(a, c, Direction.BIDIRECTIONAL, Speed.DEFAULT, f); } /** @@ -173,7 +173,7 @@ public class Effects extends GQueryQueue { * The effect goes from the center to the perimeter. */ public Effects clipAppear(Function... f) { - return clipAppear(DEFAULT_SPEED, f); + return clipAppear(Speed.DEFAULT, f); } /** @@ -192,7 +192,7 @@ public class Effects extends GQueryQueue { * The effect goes from the perimeter to the center. */ public Effects clipDisappear(Function... f) { - return clipDisappear(DEFAULT_SPEED, f); + return clipDisappear(Speed.DEFAULT, f); } /** @@ -211,7 +211,7 @@ public class Effects extends GQueryQueue { * The effect goes from the top to the bottom. */ public Effects clipDown(Function... f) { - return clipDown(DEFAULT_SPEED, f); + return clipDown(Speed.DEFAULT, f); } /** @@ -230,7 +230,7 @@ public class Effects extends GQueryQueue { * The effect goes from the bottom to the top. */ public Effects clipUp(Function... f) { - return clipUp(DEFAULT_SPEED, f); + return clipUp(Speed.DEFAULT, f); } /** @@ -250,7 +250,7 @@ public class Effects extends GQueryQueue { * some form of height and width associated with them. */ public Effects fadeIn(Function... f) { - return fadeIn(DEFAULT_SPEED, f); + return fadeIn(Speed.DEFAULT, f); } /** @@ -271,7 +271,7 @@ public class Effects extends GQueryQueue { * them. */ public Effects fadeOut(Function... f) { - return fadeOut(DEFAULT_SPEED, f); + return fadeOut(Speed.DEFAULT, f); } /** @@ -300,7 +300,7 @@ public class Effects extends GQueryQueue { * optional callback after completion. */ public Effects slideDown(Function... f) { - return slideDown(DEFAULT_SPEED, f); + return slideDown(Speed.DEFAULT, f); } /** @@ -316,7 +316,7 @@ public class Effects extends GQueryQueue { * callback after completion. */ public Effects slideLeft(Function... f) { - return slideLeft(DEFAULT_SPEED, f); + return slideLeft(Speed.DEFAULT, f); } /** @@ -332,7 +332,7 @@ public class Effects extends GQueryQueue { * optional callback after completion. */ public Effects slideRight(Function... f) { - return slideRight(DEFAULT_SPEED, f); + return slideRight(Speed.DEFAULT, f); } /** @@ -358,7 +358,7 @@ public class Effects extends GQueryQueue { * callback after completion. */ public Effects slideUp(Function... f) { - return slideUp(DEFAULT_SPEED, f); + return slideUp(Speed.DEFAULT, f); } /** @@ -374,7 +374,7 @@ public class Effects extends GQueryQueue { */ @Override public Effects toggle() { - return toggle(DEFAULT_SPEED); + return toggle(Speed.DEFAULT); } /** diff --git a/samples/src/main/java/gwtquery/samples/client/GwtQueryDemoModule.java b/samples/src/main/java/gwtquery/samples/client/GwtQueryDemoModule.java index 20baa2ae..038ee8e2 100644 --- a/samples/src/main/java/gwtquery/samples/client/GwtQueryDemoModule.java +++ b/samples/src/main/java/gwtquery/samples/client/GwtQueryDemoModule.java @@ -1,6 +1,7 @@ package gwtquery.samples.client; import static com.google.gwt.query.client.GQuery.$; +import static com.google.gwt.query.client.plugins.Effects.Effects; import com.google.gwt.core.client.EntryPoint; import com.google.gwt.core.client.GWT; @@ -11,7 +12,7 @@ import com.google.gwt.query.client.Function; import com.google.gwt.query.client.GQuery; import com.google.gwt.query.client.Selector; import com.google.gwt.query.client.Selectors; -import com.google.gwt.query.client.plugins.Effects; +import com.google.gwt.query.client.plugins.Effects.Speed; import com.google.gwt.user.client.Event; /** @@ -41,7 +42,7 @@ public class GwtQueryDemoModule implements EntryPoint { final GQuery slides = $(s.allSlides()); // we initially hide all slides and bullets - slides.hide().eq(0).as(Effects.Effects).clipAppear(); + slides.hide().eq(0).as(Effects).clipAppear(); $(s.allSlideBullets()).hide(); @@ -58,21 +59,25 @@ public class GwtQueryDemoModule implements EntryPoint { public boolean f(Event e) { // onclick, if not all bullets shown, show a bullet and increment if (curBullets < bullets.size()) { - bullets.eq(curBullets++).show(); + bullets.eq(curBullets++).as(Effects).fadeIn(Speed.SLOW); } else { // all bullets shown, hide them and current slide bullets.hide(); + // move to next slide, checking for wrap around - curSlide++; + int lastSlide = curSlide++; if (curSlide == slides.size()) { curSlide = 0; } - curBullets = 0; + // query for new set of bullets, and show next slide + curBullets = 0; bullets = $(s.slideBulletsCtx(slides.get(curSlide))); - slides.eq(curSlide - 1).as(Effects.Effects).slideLeft(new Function() { + + // Hide the last slide and show the next when the effects finishes + slides.eq(lastSlide).as(Effects).fadeOut(new Function() { public void f(Element e) { - slides.eq(curSlide).as(Effects.Effects).clipAppear(); + slides.eq(curSlide).as(Effects).clipAppear(); } }); } -- 2.39.5