diff options
2 files changed, 22 insertions, 2 deletions
diff --git a/gwtquery-core/src/main/java/com/google/gwt/query/client/plugins/effects/TransitionsAnimation.java b/gwtquery-core/src/main/java/com/google/gwt/query/client/plugins/effects/TransitionsAnimation.java index 74353323..df3da8f3 100755 --- a/gwtquery-core/src/main/java/com/google/gwt/query/client/plugins/effects/TransitionsAnimation.java +++ b/gwtquery-core/src/main/java/com/google/gwt/query/client/plugins/effects/TransitionsAnimation.java @@ -162,9 +162,17 @@ public class TransitionsAnimation extends PropertiesAnimation { if (part1 != null && !part1.isEmpty()) { double n = "-=".equals(part1) ? -1 : 1; - double st = Double.parseDouble(trsStart); + + double st = 0; + MatchResult sparts = REGEX_SYMBOL_NUMBER_UNIT.exec(trsStart); + if (sparts != null) { + st = Double.parseDouble(sparts.getGroup(2)); + unit = sparts.getGroup(3).isEmpty() ? unit : sparts.getGroup(3); + } + trsStart = "" + st + unit; + double en = Double.parseDouble(trsEnd); - trsEnd = "" + (st + (n*en)); + trsEnd = "" + (st + n*en) + unit; } // Deal with non px units like "%" diff --git a/gwtquery-core/src/test/java/com/google/gwt/query/client/GQueryEffectsTestGwt.java b/gwtquery-core/src/test/java/com/google/gwt/query/client/GQueryEffectsTestGwt.java index ac79febe..11669ba4 100644 --- a/gwtquery-core/src/test/java/com/google/gwt/query/client/GQueryEffectsTestGwt.java +++ b/gwtquery-core/src/test/java/com/google/gwt/query/client/GQueryEffectsTestGwt.java @@ -23,8 +23,10 @@ import com.google.gwt.dom.client.Element; import com.google.gwt.junit.client.GWTTestCase; import com.google.gwt.query.client.GQuery.Offset; import com.google.gwt.query.client.plugins.effects.Fx.ColorFx; +import com.google.gwt.query.client.plugins.effects.Fx.TransitFx; import com.google.gwt.query.client.plugins.effects.PropertiesAnimation; import com.google.gwt.query.client.plugins.effects.PropertiesAnimation.EasingCurve; +import com.google.gwt.query.client.plugins.effects.TransitionsAnimation; import com.google.gwt.user.client.Timer; import com.google.gwt.user.client.ui.HTML; import com.google.gwt.user.client.ui.Label; @@ -369,6 +371,16 @@ public class GQueryEffectsTestGwt extends GWTTestCase { }; timer.schedule(duration * 2); } + + public void testComputeFxPropTransitions() { + $(e).html("<table border=1 id=idtest><tr><td width=200px>A</td><td width=100px>B</td></tr></table>"); + $("#idtest").css("position", "absolute").find("td"); + final GQuery g = $("#idtest td"); + + TransitFx fx = (TransitFx)TransitionsAnimation.computeFxProp(g.get(0), "width", "+=100", false); + assertEquals("10px", fx.transitStart.replace(".0","")); + assertEquals("110px", fx.transitEnd.replace(".0","")); + } public void testStop() { $(e) |