aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorManuel Carrasco Moñino <manuel.carrasco.m@gmail.com>2013-12-07 20:46:13 +0100
committerManuel Carrasco Moñino <manuel.carrasco.m@gmail.com>2013-12-07 20:46:13 +0100
commitebd34704c08403e53a6dbf2b73213ddd2161b81c (patch)
tree7df386de4ba5986c9c874d4dc13f748e931d143c
parent8d7dbc8c4e08d637544f49f2d57614feade5567b (diff)
downloadgwtquery-ebd34704c08403e53a6dbf2b73213ddd2161b81c.tar.gz
gwtquery-ebd34704c08403e53a6dbf2b73213ddd2161b81c.zip
Consider easing and duration passed in the properties object. Fix default duration in animate.
-rwxr-xr-xgwtquery-core/src/main/java/com/google/gwt/query/client/plugins/Effects.java19
-rwxr-xr-xgwtquery-core/src/main/java/com/google/gwt/query/client/plugins/effects/PropertiesAnimation.java38
2 files changed, 32 insertions, 25 deletions
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 a14c307a..c7b66d5b 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
@@ -163,11 +163,16 @@ public class Effects extends QueuePlugin<Effects> {
* @param duration the duration in milliseconds of the animation
* @param easing the easing function to use for the transition
*/
- public Effects animate(Object stringOrProperties, final int duration,
- final Easing easing, final Function... funcs) {
+ public Effects animate(Object stringOrProperties, int duration, Easing easing, Function... funcs) {
final Properties p = (stringOrProperties instanceof String)
- ? $$((String) stringOrProperties) : (Properties) stringOrProperties;
+ ? $$((String) stringOrProperties) : (Properties) stringOrProperties;
+
+ if (p.getStr("duration") != null) {
+ duration = p.getInt("duration");
+ }
+
+ duration = Math.abs(duration);
for (Element e: elements()) {
if (Fx.css3) {
@@ -237,7 +242,7 @@ public class Effects extends QueuePlugin<Effects> {
* complete
*/
public Effects animate(Object stringOrProperties, Function... funcs) {
- return animate(stringOrProperties, 500, funcs);
+ return animate(stringOrProperties, Speed.DEFAULT, funcs);
}
/**
@@ -303,7 +308,7 @@ public class Effects extends QueuePlugin<Effects> {
* Animate the set of matched elements using the clip or scale property. It is possible to show or
* hide a set of elements, specify the direction of the animation and the start corner of the
* effect. Finally it executes the set of functions passed as arguments.
- *
+ *
* @deprecated use animate() instead
*/
@Deprecated
@@ -316,7 +321,7 @@ public class Effects extends QueuePlugin<Effects> {
* Animate the set of matched elements using the clip or scale property. It is possible to show or
* hide a set of elements, specify the direction of the animation and the start corner of the
* effect. Finally it executes the set of functions passed as arguments.
- *
+ *
* @deprecated use animate() instead
*/
@Deprecated
@@ -337,7 +342,7 @@ public class Effects extends QueuePlugin<Effects> {
* Animate the set of matched elements using the clip or scale property. It is possible to show or
* hide a set of elements, specify the direction of the animation and the start corner of the
* effect. Finally it executes the set of functions passed as arguments.
- *
+ *
* @deprecated use animate() instead
*/
@Deprecated
diff --git a/gwtquery-core/src/main/java/com/google/gwt/query/client/plugins/effects/PropertiesAnimation.java b/gwtquery-core/src/main/java/com/google/gwt/query/client/plugins/effects/PropertiesAnimation.java
index d18a220a..88e485ce 100755
--- a/gwtquery-core/src/main/java/com/google/gwt/query/client/plugins/effects/PropertiesAnimation.java
+++ b/gwtquery-core/src/main/java/com/google/gwt/query/client/plugins/effects/PropertiesAnimation.java
@@ -49,28 +49,28 @@ public class PropertiesAnimation extends GQAnimation {
*/
public Easing SWING = EasingCurve.swing;
}
-
+
/**
* This is a collection of most popular curves used in web animations
* implemented using the Bezier Curve instead of a different algorithm per
* animation.
- *
+ *
* The toString() method returns the string parameter which can be used
* for CSS3 transition-timing-function properties, example:
* <pre>
transition-timing-function: ease;
transition-timing-function: cubic-bezier(0, 0, 1, 1);
-
+
* </pre>
- *
+ *
* This enum can be used with customized transitions in this way:
* <pre>
-
+
$("#foo").animate($$("{top:'500px',left:'500px'}"), 400, EasingCurve.custom.with(.02,.01,.47,1));
-
+
* </pre>
- *
+ *
*/
public static enum EasingCurve implements Easing {
linear (0, 0, 1, 1) {
@@ -116,7 +116,7 @@ public class PropertiesAnimation extends GQAnimation {
easeOutBack (.175, .885,.32,1.275),
easeInOutBack (.68,-.55,.265,1.55),
custom(0, 0, 1, 1);
-
+
private Bezier c = new Bezier(0, 0, 1, 1);
EasingCurve(double x1, double y1, double x2, double y2) {
with(x1, y1, x2, y2);
@@ -134,12 +134,12 @@ public class PropertiesAnimation extends GQAnimation {
}
protected static final String[] ATTRS_TO_SAVE = new String[]{"overflow"};
-
+
private static final RegExp REGEX_NUMBER_UNIT = RegExp.compile("^([0-9+-.]+)(.*)?$");
protected static final RegExp REGEX_SYMBOL_NUMBER_UNIT = RegExp.compile("^([+-]=)?([0-9+-.]+)(.*)?$");
- protected static final RegExp REGEX_NON_PIXEL_ATTRS =
+ protected static final RegExp REGEX_NON_PIXEL_ATTRS =
RegExp.compile("z-?index|font-?weight|opacity|zoom|line-?height|scale|rotation|^\\$", "i");
private static final RegExp REGEX_COLOR_ATTR = RegExp.compile(".*color$", "i");
@@ -277,19 +277,21 @@ public class PropertiesAnimation extends GQAnimation {
this(null, elem, p, funcs);
}
- public PropertiesAnimation(Easing easing, Element elem, Properties p, Function... funcs) {
+ public PropertiesAnimation(Easing ease, Element elem, Properties p, Function... funcs) {
+ try {
+ easing = EasingCurve.valueOf(p.getStr("easing"));
+ } catch (Exception e) {
+ }
if (easing == null) {
- try {
- easing = EasingCurve.valueOf(p.getStr("easing"));
- } catch (Exception e) {
- easing = EasingCurve.linear;
- }
+ easing = ease;
+ }
+ if (easing == null) {
+ easing = EasingCurve.swing;
}
- this.easing = easing;
this.funcs = funcs;
setProperties(p);
setElement(elem);
-
+
g = $(e).as(Effects.Effects);
}