You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@pivot.apache.org by Bill van Melle <bi...@gmail.com> on 2011/02/19 01:56:07 UTC

run FadeTransition in reverse?

This ought to be a simple question, but there's scant documentation about
transitions...

There's a class FadeTransition, which when run fades out a component.  Is
there a way to run it backwards to fade in a component?  There's a reverse
method, but I don't understand what it's supposed to do exactly.

Re: run FadeTransition in reverse?

Posted by Chris Bartlett <cb...@gmail.com>.
As I understand it, a Transition handles changes of state from an initial
state 'A' to an end state 'B'.  (Note that the start and end states might
actually be the same, and the middle states would be adjustments from this
'normal' state)  In this case, the transition will move from state A to
state B, which I will call 'forwards'.

The reverse() method allows the direction of a *running* transition to be
toggled so that it will run 'backwards'. (or 'forwards' if called yet
again...)  This might be used to back out of a running transition, such as
cancelling the show Sheet transition if the escape key is pressed.

The getPercentComplete() method will generally be used by the update()
method of a concrete Transition implementation to determine the current
position along the transition timeline.

A quick & dirty solution might be
Transition fadeInTransition = new FadeTransition(component, duration, rate)
{
  public float getPercentComplete() {
    return 1f - super.getPercentComplete();
  };
};

Of course, you could also create your own fade transition class based on the
existing FadeTransition one, and incorporate the above along with a
Direction enum or boolean flag allowing the same transition instance to be
reused for fading a component in and out.

Chris

On 19 February 2011 07:56, Bill van Melle <bi...@gmail.com> wrote:

> This ought to be a simple question, but there's scant documentation about
> transitions...
>
> There's a class FadeTransition, which when run fades out a component.  Is
> there a way to run it backwards to fade in a component?  There's a reverse
> method, but I don't understand what it's supposed to do exactly.
>