]> source.dussan.org Git - gwtquery.git/commitdiff
make Easing an interface instead of an Enum. Users can easily their own easing functi...
authorJulien Dramaix <julien.dramaix@gmail.com>
Sat, 2 Apr 2011 08:41:59 +0000 (08:41 +0000)
committerJulien Dramaix <julien.dramaix@gmail.com>
Sat, 2 Apr 2011 08:41:59 +0000 (08:41 +0000)
gwtquery-core/src/main/java/com/google/gwt/query/client/plugins/effects/PropertiesAnimation.java

index b69cfb83049b3c2534065133c7b5decf683397ff..a5669535654d98dad5a11c8aeedc152766ce1906 100755 (executable)
@@ -34,8 +34,20 @@ public class PropertiesAnimation extends Animation {
   /**\r
    * Easing method to use.\r
    */\r
-  public enum Easing {\r
-    LINEAR, SWING\r
+  public static interface Easing {\r
+    public double interpolate(double progress);\r
+    \r
+    public Easing LINEAR = new Easing() {     \r
+      public double interpolate(double progress) {\r
+        return progress;\r
+      }\r
+    };\r
+    \r
+    public Easing SWING = new Easing() {     \r
+      public double interpolate(double progress) {\r
+       return (1 + Math.cos(Math.PI + progress * Math.PI)) / 2;\r
+      }\r
+    };\r
   }\r
   \r
   /**\r
@@ -202,11 +214,11 @@ public class PropertiesAnimation extends Animation {
 \r
   @Override\r
   protected double interpolate(double progress) {\r
-    if (easing == Easing.SWING) {\r
-      return super.interpolate(progress);\r
-    } else {\r
-      return progress;\r
+    if (easing != null){\r
+      return easing.interpolate(progress);\r
     }\r
+    //maybe return super.interpolate() instead ?\r
+    return progress;\r
   }\r
 \r
 }\r