OSDN Git Service

Slider, fixed animation.
authorNathanSweet <nathan.sweet@gmail.com>
Sat, 26 Jan 2013 16:42:20 +0000 (17:42 +0100)
committerNathanSweet <nathan.sweet@gmail.com>
Sat, 26 Jan 2013 16:42:20 +0000 (17:42 +0100)
gdx/src/com/badlogic/gdx/scenes/scene2d/ui/Slider.java

index 379cbb1..53380bc 100644 (file)
@@ -209,7 +209,7 @@ public class Slider extends Widget {
 \r
        /** If {@link #setAnimateDuration(float) animating} the slider value, this returns the value current displayed. */\r
        public float getVisualValue () {\r
-               if (animateTime > 0) return animateInterpolation.apply(animateFromValue, value, animateTime / animateDuration);\r
+               if (animateTime > 0) return animateInterpolation.apply(animateFromValue, value, 1 - animateTime / animateDuration);\r
                return value;\r
        }\r
 \r
@@ -219,13 +219,14 @@ public class Slider extends Widget {
                value = MathUtils.clamp(Math.round(value / stepSize) * stepSize, min, max);\r
                float oldValue = this.value;\r
                if (value == oldValue) return;\r
+               float oldVisualValue = getVisualValue();\r
                this.value = value;\r
                ChangeEvent changeEvent = Pools.obtain(ChangeEvent.class);\r
                if (fire(changeEvent))\r
                        this.value = oldValue;\r
                else if (animateDuration > 0) {\r
+                       animateFromValue = oldVisualValue;\r
                        animateTime = animateDuration;\r
-                       animateFromValue = getVisualValue();\r
                }\r
                Pools.free(changeEvent);\r
        }\r