From: Julien Dramaix Date: Sat, 2 Apr 2011 08:41:59 +0000 (+0000) Subject: make Easing an interface instead of an Enum. Users can easily their own easing functi... X-Git-Tag: release-1.3.2~439 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=9a14af5e8c88e8b33fb6e98dba1e737eee47dbea;p=gwtquery.git make Easing an interface instead of an Enum. Users can easily their own easing function. That allows also defining others easing functions in a plugin --- 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 b69cfb83..a5669535 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 @@ -34,8 +34,20 @@ public class PropertiesAnimation extends Animation { /** * Easing method to use. */ - public enum Easing { - LINEAR, SWING + public static interface Easing { + public double interpolate(double progress); + + public Easing LINEAR = new Easing() { + public double interpolate(double progress) { + return progress; + } + }; + + public Easing SWING = new Easing() { + public double interpolate(double progress) { + return (1 + Math.cos(Math.PI + progress * Math.PI)) / 2; + } + }; } /** @@ -202,11 +214,11 @@ public class PropertiesAnimation extends Animation { @Override protected double interpolate(double progress) { - if (easing == Easing.SWING) { - return super.interpolate(progress); - } else { - return progress; + if (easing != null){ + return easing.interpolate(progress); } + //maybe return super.interpolate() instead ? + return progress; } }