package com.google.gwt.query.client;\r
\r
import static com.google.gwt.query.client.GQuery.$;\r
+import static com.google.gwt.query.client.GQuery.$$;\r
\r
import java.util.Date;\r
\r
import com.google.gwt.event.dom.client.FocusHandler;\r
import com.google.gwt.event.shared.GwtEvent;\r
import com.google.gwt.event.shared.HandlerRegistration;\r
+import com.google.gwt.query.client.GQuery.Offset;\r
import com.google.gwt.query.client.js.JsCache;\r
import com.google.gwt.query.client.js.JsNodeArray;\r
import com.google.gwt.query.client.js.JsUtils;\r
+import com.google.gwt.query.client.plugins.Effects;\r
import com.google.gwt.query.client.plugins.effects.PropertiesAnimation;\r
import com.google.gwt.query.client.plugins.effects.PropertiesAnimation.Easing;\r
import com.google.gwt.user.client.Event;\r
public void onModuleLoad() {\r
try {\r
gwtSetUp();\r
- testChrome__gwt_ObjectId();\r
+ testAttrEffect();\r
} catch (Exception ex) {\r
ex.printStackTrace();\r
$(e).html("").after("<div>ERROR: " + ex.getMessage() + "</div>");\r
}\r
}\r
\r
+ public void testAttrEffect() {\r
+ $(e).html("<table border=1 id=idtest width=440><tr><td width=50%>A</td><td width=50%>B</td></tr></table>");\r
+\r
+ final GQuery g = $("#idtest").css("position", "absolute");\r
+ final int duration = 2000;\r
+ \r
+ assertEquals("cssprop=$width attr=width value=+=100 start=440 end=540 unit=", \r
+ PropertiesAnimation.computeFxProp(g.get(0), "$width", "+=100", false).toString());\r
+ \r
+ delayTestFinish(duration * 3);\r
+\r
+ g.as(Effects.Effects).\r
+ animate($$("$width: +=100; $border: +=4"), duration, Easing.LINEAR);\r
+ \r
+ final Timer timer = new Timer() {\r
+ public void run() {\r
+ assertEquals(540.0, Double.parseDouble(g.attr("width")));\r
+ assertEquals(5.0, Double.parseDouble(g.attr("border")));\r
+ finishTest();\r
+ }\r
+ };\r
+ timer.schedule(duration * 2);\r
+ }\r
+ \r
public void testChrome__gwt_ObjectId() {\r
JsCache a = JsCache.create();\r
assertEquals(0, a.length());\r
import com.google.gwt.user.client.Timer;\r
import com.google.gwt.user.client.ui.HTML;\r
import com.google.gwt.user.client.ui.RootPanel;\r
+import static com.google.gwt.query.client.GQuery.*;\r
\r
/**\r
* Just a simple class to emulate JUnit TestCase.\r
testRunning = false;\r
}\r
\r
- \r
+ protected void assertPosition(GQuery g, Offset min, Offset max) {\r
+ int a = Math.min(min.top, max.top);\r
+ int b = Math.max(min.top, max.top);\r
+ int v = g.offset().top;\r
+ boolean c = a <= v && v <= b;\r
+ String msg = "Top has the value " + v + ", but should be in the range: "\r
+ + a + " - " + b;\r
+ assertTrue(msg, c);\r
+\r
+ a = Math.min(min.left, max.left);\r
+ b = Math.max(min.left, max.left);\r
+ v = g.offset().left;\r
+ c = a <= v && v <= b;\r
+ msg = "Left has the value " + v + ", but should be in the range: " + a\r
+ + " - " + b;\r
+ assertTrue(msg, c);\r
+ }\r
}\r
+++ /dev/null
-/*
- * Copyright 2011, The gwtquery team.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"); you may not
- * use this file except in compliance with the License. You may obtain a copy of
- * the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
- * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
- * License for the specific language governing permissions and limitations under
- * the License.
- */
-package com.google.gwt.query.client.plugins.effects;
-
-import com.google.gwt.dom.client.Element;
-import com.google.gwt.query.client.GQuery;
-import com.google.gwt.query.client.css.BorderColorProperty;
-import com.google.gwt.query.client.css.CSS;
-import com.google.gwt.query.client.css.RGBColor;
-import com.google.gwt.query.client.js.JsNamedArray;
-import com.google.gwt.query.client.js.JsObjectArray;
-import com.google.gwt.query.client.js.JsRegexp;
-import com.google.gwt.query.client.plugins.effects.PropertiesAnimation.Effect;
-
-public class ColorEffect extends Effect {
-
- /**
- * Specific class handle specific borderColor shortcut properties
- *
- */
- public static class BorderColorEffect extends ColorEffect {
-
- private static BorderColorProperty[] borderColorProperties = {
- CSS.BORDER_BOTTOM_COLOR, CSS.BORDER_TOP_COLOR, CSS.BORDER_LEFT_COLOR,
- CSS.BORDER_RIGHT_COLOR};
- private JsNamedArray<int[]> startColors;
-
- public BorderColorEffect(Element e, String endColorString) {
-
- endColor = parseColor(endColorString);
- startColors = JsNamedArray.create();
-
- GQuery $e = GQuery.$(e);
-
- for (BorderColorProperty border : borderColorProperties) {
- int[] startColor = parseColor($e.css(border, true));
- startColors.put(border.getCssName(), startColor);
- }
- }
-
- @Override
- public void applyValue(GQuery g, double progress) {
- for (BorderColorProperty border : borderColorProperties) {
- startColor = startColors.get(border.getCssName());
- attr = border.getCssName();
- super.applyValue(g, progress);
- }
- }
- }
-
- // hexadecimal regex
- private static JsRegexp HEXADECIMAL_COLOR_PATTERN = new JsRegexp(
- "#([a-fA-F0-9]{6}|[a-fA-F0-9]{3})");
- private static JsNamedArray<int[]> htmlColorToRgb;
-
- // rgb and rgba regex
- private static JsRegexp RGB_COLOR_PATTERN = new JsRegexp(
- "rgba?\\(\\s*([0-9]{1,3}%?)\\s*,\\s*([0-9]{1,3}%?)\\s*,\\s*([0-9]{1,3}%?).*\\)$");
-
- static {
- htmlColorToRgb = JsNamedArray.create();
- htmlColorToRgb.put("white", new int[]{255, 255, 255});
- htmlColorToRgb.put("aqua", new int[]{0, 255, 255});
- htmlColorToRgb.put("azure", new int[]{240, 255, 255});
- htmlColorToRgb.put("beige", new int[]{245, 245, 220});
- htmlColorToRgb.put("black", new int[]{0, 0, 0});
- htmlColorToRgb.put("blue", new int[]{0, 0, 255});
- htmlColorToRgb.put("brown", new int[]{165, 42, 42});
- htmlColorToRgb.put("cyan", new int[]{0, 255, 255});
- htmlColorToRgb.put("darkblue", new int[]{0, 0, 139});
- htmlColorToRgb.put("darkcyan", new int[]{0, 139, 139});
- htmlColorToRgb.put("darkgrey", new int[]{169, 169, 169});
- htmlColorToRgb.put("darkgreen", new int[]{0, 100, 0});
- htmlColorToRgb.put("darkkhaki", new int[]{189, 183, 107});
- htmlColorToRgb.put("darkmagenta", new int[]{139, 0, 139});
- htmlColorToRgb.put("darkolivegreen", new int[]{85, 107, 47});
- htmlColorToRgb.put("darkorange", new int[]{255, 140, 0});
- htmlColorToRgb.put("darkorchid", new int[]{153, 50, 204});
- htmlColorToRgb.put("darkred", new int[]{139, 0, 0});
- htmlColorToRgb.put("darksalmon", new int[]{233, 150, 122});
- htmlColorToRgb.put("darkviolet", new int[]{148, 0, 211});
- htmlColorToRgb.put("fuchsia", new int[]{255, 0, 255});
- htmlColorToRgb.put("gold", new int[]{255, 215, 0});
- htmlColorToRgb.put("green", new int[]{0, 128, 0});
- htmlColorToRgb.put("indigo", new int[]{75, 0, 130});
- htmlColorToRgb.put("khaki", new int[]{240, 230, 140});
- htmlColorToRgb.put("lightblue", new int[]{173, 216, 230});
- htmlColorToRgb.put("lightcyan", new int[]{224, 255, 255});
- htmlColorToRgb.put("lightgreen", new int[]{144, 238, 144});
- htmlColorToRgb.put("lightgrey", new int[]{211, 211, 211});
- htmlColorToRgb.put("lightpink", new int[]{255, 182, 193});
- htmlColorToRgb.put("lightyellow", new int[]{255, 255, 224});
- htmlColorToRgb.put("lime", new int[]{0, 255, 0});
- htmlColorToRgb.put("magenta", new int[]{255, 0, 255});
- htmlColorToRgb.put("maroon", new int[]{128, 0, 0});
- htmlColorToRgb.put("navy", new int[]{0, 0, 128});
- htmlColorToRgb.put("olive", new int[]{128, 128, 0});
- htmlColorToRgb.put("orange", new int[]{255, 165, 0});
- htmlColorToRgb.put("pink", new int[]{255, 192, 203});
- htmlColorToRgb.put("purple", new int[]{128, 0, 128});
- htmlColorToRgb.put("violet", new int[]{128, 0, 128});
- htmlColorToRgb.put("red", new int[]{255, 0, 0});
- htmlColorToRgb.put("silver", new int[]{192, 192, 192});
- htmlColorToRgb.put("white", new int[]{255, 255, 255});
- htmlColorToRgb.put("yellow", new int[]{255, 255, 0});
-
- }
-
- protected int[] endColor;
- protected int[] startColor;
-
- ColorEffect(String attr, String startColorString, String endColorString) {
- assert startColorString != null && endColorString != null;
- this.attr = attr;
- startColor = parseColor(startColorString);
- endColor = parseColor(endColorString);
- }
-
- private ColorEffect() {
- }
-
- @Override
- public void applyValue(GQuery g, double progress) {
- int[] result = new int[3];
- for (int i = 0; i < 3; i++) {
- int composante = (int) Math.round(startColor[i] + progress
- * (endColor[i] - startColor[i]));
- result[i] = Math.max(0, Math.min(255, composante));
- }
- String value = RGBColor.rgb(result[0], result[1], result[2]).getCssName();
-
- g.css(attr, value);
- }
-
- public int[] getEndColor() {
- return endColor;
- }
-
- public int[] getStartColor() {
- return startColor;
- }
-
- protected int[] parseColor(String color) {
- JsObjectArray<String> matches = RGB_COLOR_PATTERN.exec(color);
- if (matches != null) {
- return parseRGBColor(matches);
- }
-
- matches = HEXADECIMAL_COLOR_PATTERN.exec(color);
- if (matches != null) {
- return parseHexColor(matches);
- }
-
- return parseLiteralColor(color);
- }
-
- private int[] parseHexColor(JsObjectArray<String> matches) {
- assert matches.length() == 2;
- int[] result = new int[3];
-
- String hexCode = matches.get(1);
-
- int step = (hexCode.length() == 3) ? 1 : 2;
-
- for (int i = 0; i < 3; i++) {
- String color = hexCode.substring(i * step, (i * step) + step);
- if (step == 1) {
- color += color;
- }
- result[i] = Math.max(0, Math.min(255, Integer.parseInt(color, 16)));
-
- }
-
- return result;
- }
-
- private int[] parseLiteralColor(String color) {
- return htmlColorToRgb.get(color);
- }
-
- private int[] parseRGBColor(JsObjectArray<String> matches) {
- assert matches.length() == 4;
- int[] result = new int[3];
-
- for (int i = 1; i < 4; i++) {
- String valueString = matches.get(i);
- int value = -1;
- if (valueString.endsWith("%")) {
- int percentage = Integer.parseInt(valueString.substring(0,
- valueString.length() - 1));
- value = Math.round((float) 2.55 * percentage);
- } else {
- value = Integer.parseInt(valueString);
- }
- result[i - 1] = Math.max(0, Math.min(255, value));
- }
- return result;
- }
-
-}
\ No newline at end of file
import com.google.gwt.query.client.js.JsObjectArray;\r
import com.google.gwt.query.client.js.JsRegexp;\r
import com.google.gwt.query.client.plugins.Effects;\r
-import com.google.gwt.query.client.plugins.effects.ColorEffect.BorderColorEffect;\r
-\r
-import java.util.ArrayList;\r
+import com.google.gwt.query.client.plugins.effects.Fx.ColorFx;\r
+import com.google.gwt.query.client.plugins.effects.Fx.ColorFx.BorderColorFx;\r
\r
/**\r
* Animation effects on any numeric CSS property.\r
};\r
}\r
\r
- /**\r
- * A pojo to store effect values.\r
- */\r
- public static class Effect {\r
-\r
- public String attr;\r
- public double end;\r
- public double start;\r
- public String unit;\r
- public String value;\r
-\r
- Effect() {\r
- end = start = -1;\r
- }\r
-\r
- Effect(String attr, String value, double start, double end, String unit) {\r
- this.attr = attr;\r
- this.value = value;\r
- this.start = start;\r
- this.end = end;\r
- this.unit = unit;\r
- }\r
-\r
- public void applyValue(GQuery g, double progress) {\r
+ private static final String[] ATTRS_TO_SAVE = new String[]{\r
+ "overflow", "visibility"};\r
\r
- double ret = (start + ((end - start) * progress));\r
- String value = ("px".equals(unit) ? ((int) ret) : ret) + unit;\r
+ private static final JsRegexp REGEX_NUMBER_UNIT = new JsRegexp(\r
+ "^([0-9+-.]+)(.*)?$");\r
\r
- g.css(attr, value);\r
- }\r
+ private static final JsRegexp REGEX_SYMBOL_NUMBER_UNIT = new JsRegexp(\r
+ "^([+-]=)?([0-9+-.]+)(.*)?$");\r
\r
- public String toString() {\r
- return ("attr=" + attr + " value=" + value + " start=" + start + " end="\r
- + end + " unit=" + unit).replaceAll("\\.0([^\\d])", "$1");\r
- }\r
- }\r
+ private static final JsRegexp REGEX_NON_PIXEL_ATTRS = new JsRegexp(\r
+ "z-?index|font-?weight|opacity|zoom|line-?height|^\\$", "i");\r
\r
- private static final String[] attrsToSave = new String[]{\r
- "overflow", "visibility"};\r
+ private static final JsRegexp REGEX_COLOR_ATTR = new JsRegexp(".*color$", "i");\r
\r
- private static JsRegexp nonPxRegExp = new JsRegexp(\r
- "z-?index|font-?weight|opacity|zoom|line-?height", "i");\r
+ private static final JsRegexp REGEX_BORDERCOLOR = new JsRegexp("^bordercolor$", "i");\r
\r
- private static JsRegexp colorRegExp = new JsRegexp(".*color$", "i");\r
- public static JsRegexp RGB_COLOR_PATTERN = new JsRegexp(\r
- "rgb\\(\\s*([0-9]{1,3}%?)\\s*,\\s*([0-9]{1,3}%?)\\s*,\\s*([0-9]{1,3}%?)\\s*\\)$");\r
- public static JsRegexp HEXADECIMAL_COLOR_PATTERN = new JsRegexp(\r
- "^#([a-fA-F0-9]{6}|[a-fA-F0-9]{3})$");\r
+ private static final JsRegexp REGEX_BACKGROUNDCOLOR = new JsRegexp("^backgroundcolor$", "i");\r
+ \r
+ \r
\r
- public static Effect computeFxProp(Element e, String key, String val,\r
+ public static Fx computeFxProp(Element e, String key, String val,\r
boolean hidden) {\r
\r
- if (colorRegExp.test(key)) {\r
+ if (REGEX_COLOR_ATTR.test(key)) {\r
return computeFxColorProp(e, key, val);\r
}\r
\r
return computeFxNumericProp(e, key, val, hidden);\r
}\r
\r
- private static Effect computeFxColorProp(Element e, String key, String val) {\r
+ private static Fx computeFxColorProp(Element e, String key, String val) {\r
\r
- if ("BORDERCOLOR".equals(key.toUpperCase())) {\r
- return new BorderColorEffect(e, val);\r
+ if (REGEX_BORDERCOLOR.test(key)) {\r
+ return new BorderColorFx(e, val);\r
}\r
\r
String initialColor = null;\r
-\r
- if ("BACKGROUNDCOLOR".equals(key.toUpperCase())) {\r
+ if (REGEX_BACKGROUNDCOLOR.test(key)) {\r
// find the first parent having a background-color value (other than\r
// transparent)\r
Element current = e;\r
initialColor = GQuery.$(e).css(key, true);\r
}\r
\r
- return new ColorEffect(key, initialColor, val);\r
+ return new ColorFx(key, initialColor, val);\r
}\r
\r
- public static Effect computeFxNumericProp(Element e, String key, String val,\r
+ public static Fx computeFxNumericProp(Element e, String key, String val,\r
boolean hidden) {\r
\r
GQuery g = Effects.$(e);\r
if (hidden) {\r
g.show();\r
}\r
- double start = g.cur(key, true), end = start;\r
+\r
+ // If key starts with $ we animate node attributes, otherwise css properties\r
+ double cur;\r
+ String rkey = null;\r
+ if (key.startsWith("$")) {\r
+ rkey = key.substring(1).toLowerCase();\r
+ String attr = g.attr(rkey);\r
+ JsObjectArray<String> parts = REGEX_NUMBER_UNIT.match(attr);\r
+ if (parts != null) {\r
+ String $1 = parts.get(1);\r
+ String $2 = parts.get(2);\r
+ cur = Double.parseDouble($1);\r
+ unit = $2 == null ? "" : $2;\r
+ } else {\r
+ cur = g.cur(key, true);\r
+ key = rkey;\r
+ }\r
+ } else {\r
+ cur = g.cur(key, true);\r
+ }\r
+\r
+ double start = cur, end = start;\r
\r
if ("show".equals(val)) {\r
g.saveCssAttrs(key);\r
start = 0;\r
- unit = nonPxRegExp.test(key) ? "" : "px";\r
+ unit = REGEX_NON_PIXEL_ATTRS.test(key) ? "" : "px";\r
} else if ("hide".equals(val)) {\r
if (hidden) {\r
return null;\r
}\r
g.saveCssAttrs(key);\r
end = 0;\r
- unit = nonPxRegExp.test(key) ? "" : "px";\r
+ unit = REGEX_NON_PIXEL_ATTRS.test(key) ? "" : "px";\r
} else {\r
- JsObjectArray<String> parts = new JsRegexp("^([+-]=)?([0-9+-.]+)(.*)?$").match(val);\r
+ JsObjectArray<String> parts = REGEX_SYMBOL_NUMBER_UNIT.match(val);\r
\r
if (parts != null) {\r
String $1 = parts.get(1);\r
String $2 = parts.get(2);\r
String $3 = parts.get(3);\r
end = Double.parseDouble($2);\r
- unit = nonPxRegExp.test(key) ? "" : $3 == null || $3.isEmpty() ? "px"\r
- : $3;\r
- if (!"px".equals(unit)) {\r
- double to = end == 0 ? 1 : end;\r
- g.css(key, to + unit);\r
- start = to * start / g.cur(key, true);\r
- g.css(key, start + unit);\r
+ \r
+ if (rkey == null) {\r
+ unit = REGEX_NON_PIXEL_ATTRS.test(key) ? "" : //\r
+ $3 == null || $3.isEmpty() ? "px" : $3;\r
+ if (!"px".equals(unit)) {\r
+ double to = end == 0 ? 1 : end;\r
+ g.css(key, to + unit);\r
+ start = to * start / g.cur(key, true);\r
+ g.css(key, start + unit);\r
+ }\r
+ } else if ($3 != null && !$3.isEmpty()) {\r
+ unit = $3;\r
}\r
+\r
if ($1 != null && !$1.isEmpty()) {\r
end = (("-=".equals($1) ? -1 : 1) * end) + start;\r
}\r
}\r
}\r
-\r
- Effect fx = new Effect(key, val, start, end, unit);\r
- return fx;\r
+ \r
+ return new Fx(key, val, start, end, unit, rkey);\r
}\r
\r
private Element e;\r
private Easing easing = Easing.SWING;\r
- private ArrayList<Effect> effects = new ArrayList<Effect>();\r
+ private JsObjectArray<Fx> effects = JsObjectArray.create();\r
private Function[] funcs;\r
\r
private Effects g;\r
@Override\r
public void onComplete() {\r
super.onComplete();\r
- for (Effect l : effects) {\r
- if ("hide".equals(l.value)) {\r
+ for (int i = 0; i < effects.length(); i++) {\r
+ Fx fx = effects.get(i);\r
+ if ("hide".equals(fx.value)) {\r
g.hide();\r
- g.restoreCssAttrs(l.attr);\r
- } else if ("show".equals(l.value)) {\r
+ g.restoreCssAttrs(fx.cssprop);\r
+ } else if ("show".equals(fx.value)) {\r
g.show();\r
- g.restoreCssAttrs(l.attr);\r
+ g.restoreCssAttrs(fx.cssprop);\r
}\r
}\r
- g.restoreCssAttrs(attrsToSave);\r
+ g.restoreCssAttrs(ATTRS_TO_SAVE);\r
g.each(funcs);\r
g.dequeue();\r
}\r
boolean resize = false;\r
boolean move = false;\r
boolean hidden = !g.visible();\r
- Effect fx;\r
+ Fx fx;\r
// g.show();\r
for (String key : prps.keys()) {\r
String val = prps.getStr(key);\r
move = move || "top".equals(key) || "left".equals(key);\r
}\r
}\r
- g.saveCssAttrs(attrsToSave);\r
+ g.saveCssAttrs(ATTRS_TO_SAVE);\r
if (resize) {\r
g.css("overflow", "hidden");\r
}\r
\r
@Override\r
public void onUpdate(double progress) {\r
- for (Effect fx : effects) {\r
- fx.applyValue(g, progress);\r
-\r
+ for (int i = 0; i < effects.length(); i++) {\r
+ effects.get(i).applyValue(g, progress);\r
}\r
}\r
\r
import com.google.gwt.junit.client.GWTTestCase;
import com.google.gwt.query.client.GQuery.Offset;
import com.google.gwt.query.client.plugins.Effects;
-import com.google.gwt.query.client.plugins.effects.ColorEffect;
+import com.google.gwt.query.client.plugins.effects.Fx.ColorFx;
import com.google.gwt.query.client.plugins.effects.PropertiesAnimation;
import com.google.gwt.query.client.plugins.effects.PropertiesAnimation.Easing;
import com.google.gwt.user.client.Timer;
timer2.schedule(duration/2);
}
- public void disable_testEffectsShouldBeQueued() {
+ public void testEffectsShouldBeQueued() {
$(e).html("<p id='idtest'>Content 1</p></p>");
final GQuery g = $("#idtest").css("position", "absolute");
timer4.schedule(duration/2);
}
- public void disable_testFade() {
+ public void testFade() {
$(e)
.html(
"<p id='id1' style='display: inline'>Content 1</p><p id='id2'>Content 2</p><p id='id3'>Content 3</p>");
GQuery g = $("#child");
Properties prop1;
- assertEquals("attr=marginTop value=-110px start=0 end=-110 unit=px",
+ assertEquals("cssprop=marginTop value=-110px start=0 end=-110 unit=px",
PropertiesAnimation.computeFxProp(g.get(0), "marginTop", "-110px",
false).toString());
- assertEquals("attr=marginLeft value=-110px start=0 end=-110 unit=px",
+ assertEquals("cssprop=marginLeft value=-110px start=0 end=-110 unit=px",
PropertiesAnimation.computeFxProp(g.get(0), "marginLeft", "-110px",
false).toString());
- assertEquals("attr=top value=50% start=0 end=50 unit=%",
+ assertEquals("cssprop=top value=50% start=0 end=50 unit=%",
PropertiesAnimation.computeFxProp(g.get(0), "top", "50%", false)
.toString());
- assertEquals("attr=left value=50% start=0 end=50 unit=%",
+ assertEquals("cssprop=left value=50% start=0 end=50 unit=%",
PropertiesAnimation.computeFxProp(g.get(0), "left", "50%", false)
.toString());
- assertEquals("attr=width value=174px start=100 end=174 unit=px",
+ assertEquals("cssprop=width value=174px start=100 end=174 unit=px",
PropertiesAnimation.computeFxProp(g.get(0), "width", "174px", false)
.toString());
- assertEquals("attr=height value=174px start=100 end=174 unit=px",
+ assertEquals("cssprop=height value=174px start=100 end=174 unit=px",
PropertiesAnimation.computeFxProp(g.get(0), "height", "174px", false)
.toString());
- assertEquals("attr=padding value=20px start=5 end=20 unit=px",
+ assertEquals("cssprop=padding value=20px start=5 end=20 unit=px",
PropertiesAnimation.computeFxProp(g.get(0), "padding", "20px", false)
.toString());
an.onStart();
an.onComplete();
- assertEquals("attr=marginTop value=0 start=-110 end=0 unit=px",
+ assertEquals("cssprop=marginTop value=0 start=-110 end=0 unit=px",
PropertiesAnimation.computeFxProp(g.get(0), "marginTop", "0", false)
.toString());
- assertEquals("attr=marginLeft value=0 start=-110 end=0 unit=px",
+ assertEquals("cssprop=marginLeft value=0 start=-110 end=0 unit=px",
PropertiesAnimation.computeFxProp(g.get(0), "marginLeft", "0", false)
.toString());
- assertEquals("attr=top value=0% start=50 end=0 unit=%", PropertiesAnimation
+ assertEquals("cssprop=top value=0% start=50 end=0 unit=%", PropertiesAnimation
.computeFxProp(g.get(0), "top", "0%", false).toString());
- assertEquals("attr=left value=0% start=50 end=0 unit=%",
+ assertEquals("cssprop=left value=0% start=50 end=0 unit=%",
PropertiesAnimation.computeFxProp(g.get(0), "left", "0%", false)
.toString());
- assertEquals("attr=width value=100px start=174 end=100 unit=px",
+ assertEquals("cssprop=width value=100px start=174 end=100 unit=px",
PropertiesAnimation.computeFxProp(g.get(0), "width", "100px", false)
.toString());
- assertEquals("attr=height value=100px start=174 end=100 unit=px",
+ assertEquals("cssprop=height value=100px start=174 end=100 unit=px",
PropertiesAnimation.computeFxProp(g.get(0), "height", "100px", false)
.toString());
- assertEquals("attr=padding value=5px start=20 end=5 unit=px",
+ assertEquals("cssprop=padding value=5px start=20 end=5 unit=px",
PropertiesAnimation.computeFxProp(g.get(0), "padding", "5px", false)
.toString());
an.onStart();
an.onComplete();
- assertEquals("attr=marginTop value=-110px start=0 end=-110 unit=px",
+ assertEquals("cssprop=marginTop value=-110px start=0 end=-110 unit=px",
PropertiesAnimation.computeFxProp(g.get(0), "marginTop", "-110px",
false).toString());
- assertEquals("attr=marginLeft value=-110px start=0 end=-110 unit=px",
+ assertEquals("cssprop=marginLeft value=-110px start=0 end=-110 unit=px",
PropertiesAnimation.computeFxProp(g.get(0), "marginLeft", "-110px",
false).toString());
- assertEquals("attr=top value=50% start=0 end=50 unit=%",
+ assertEquals("cssprop=top value=50% start=0 end=50 unit=%",
PropertiesAnimation.computeFxProp(g.get(0), "top", "50%", false)
.toString());
- assertEquals("attr=left value=50% start=0 end=50 unit=%",
+ assertEquals("cssprop=left value=50% start=0 end=50 unit=%",
PropertiesAnimation.computeFxProp(g.get(0), "left", "50%", false)
.toString());
- assertEquals("attr=width value=174px start=100 end=174 unit=px",
+ assertEquals("cssprop=width value=174px start=100 end=174 unit=px",
PropertiesAnimation.computeFxProp(g.get(0), "width", "174px", false)
.toString());
- assertEquals("attr=height value=174px start=100 end=174 unit=px",
+ assertEquals("cssprop=height value=174px start=100 end=174 unit=px",
PropertiesAnimation.computeFxProp(g.get(0), "height", "174px", false)
.toString());
- assertEquals("attr=padding value=20px start=5 end=20 unit=px",
+ assertEquals("cssprop=padding value=20px start=5 end=20 unit=px",
PropertiesAnimation.computeFxProp(g.get(0), "padding", "20px", false)
.toString());
}
String html = "<div id='test' style='color: #112233'>Test</div>";
$(e).html(html);
- ColorEffect effect = (ColorEffect) PropertiesAnimation.computeFxProp($("#test",e).get(0), "color", "#ffffff", false);
+ ColorFx effect = (ColorFx) PropertiesAnimation.computeFxProp($("#test",e).get(0), "color", "#ffffff", false);
assertEquals(17, effect.getStartColor()[0]); //#11
assertEquals(34, effect.getStartColor()[1]); //#22
assertEquals(51, effect.getStartColor()[2]); //#33
assertEquals(255, effect.getEndColor()[1]);
assertEquals(255, effect.getEndColor()[2]);
- effect = (ColorEffect) PropertiesAnimation.computeFxProp(e, "color", "rgb(255,255,255)", false);
+ effect = (ColorFx) PropertiesAnimation.computeFxProp(e, "color", "rgb(255,255,255)", false);
assertEquals(255, effect.getEndColor()[0]);
assertEquals(255, effect.getEndColor()[1]);
assertEquals(255, effect.getEndColor()[2]);
- effect = (ColorEffect) PropertiesAnimation.computeFxProp(e, "color", "rgb(100%, 100%, 100%)", false);
+ effect = (ColorFx) PropertiesAnimation.computeFxProp(e, "color", "rgb(100%, 100%, 100%)", false);
assertEquals(255, effect.getEndColor()[0]);
assertEquals(255, effect.getEndColor()[1]);
assertEquals(255, effect.getEndColor()[2]);
- effect = (ColorEffect) PropertiesAnimation.computeFxProp(e, "color", "white", false);
+ effect = (ColorFx) PropertiesAnimation.computeFxProp(e, "color", "white", false);
assertEquals(255, effect.getEndColor()[0]);
assertEquals(255, effect.getEndColor()[1]);
assertEquals(255, effect.getEndColor()[2]);
assertTrue(msg, c);
}
+ public void testAttrEffect() {
+ $(e).html("<table border=1 id=idtest width=440><tr><td width=50%>A</td><td width=50%>B</td></tr></table>");
+
+ final GQuery g = $("#idtest").css("position", "absolute");
+ final int duration = 500;
+
+ assertEquals("cssprop=$width attr=width value=+=100 start=440 end=540 unit=",
+ PropertiesAnimation.computeFxProp(g.get(0), "$width", "+=100", false).toString());
+
+ delayTestFinish(duration * 3);
+
+ g.as(Effects.Effects).
+ animate($$("$width: +=100; $border: +=4"), duration, Easing.LINEAR);
+
+ final Timer timer = new Timer() {
+ public void run() {
+ assertEquals(540.0, Double.parseDouble(g.attr("width")));
+ assertEquals(5.0, Double.parseDouble(g.attr("border")));
+ finishTest();
+ }
+ };
+ timer.schedule(duration * 2);
+ }
+
}