public abstract class Animation extends Object
Animation
is a continuous event that updates progressively over
time at a non-fixed frame rate.Modifier | Constructor and Description |
---|---|
|
Animation()
Construct a new
Animation . |
protected |
Animation(AnimationScheduler scheduler)
Construct a new
AnimationScheduler using the specified scheduler to
sheduler request frames. |
Modifier and Type | Method and Description |
---|---|
void |
cancel()
Immediately cancel this animation.
|
protected double |
interpolate(double progress)
Interpolate the linear progress into a more natural easing function.
|
boolean |
isRunning()
Returns true if the animation is running.
|
protected void |
onCancel()
Called immediately after the animation is canceled.
|
protected void |
onComplete()
Called immediately after the animation completes.
|
protected void |
onStart()
Called immediately before the animation starts.
|
protected abstract void |
onUpdate(double progress)
Called when the animation should be updated.
|
void |
run(int duration)
Immediately run this animation.
|
void |
run(int duration,
double startTime)
Run this animation at the given startTime.
|
void |
run(int duration,
double startTime,
Element element)
Run this animation at the given startTime.
|
void |
run(int duration,
Element element)
Immediately run this animation.
|
public Animation()
Animation
.protected Animation(AnimationScheduler scheduler)
AnimationScheduler
using the specified scheduler to
sheduler request frames.scheduler
- an AnimationScheduler
instancepublic void cancel()
onCancel()
will be called.public void run(int duration)
This is equivalent to run(duration, null)
.
duration
- the duration of the animation in millisecondsrun(int, Element)
public void run(int duration, Element element)
If the element is not null
, the onUpdate(double)
method might be called only if the element may be visible (generally left
at the appreciation of the browser). Otherwise, it will be called
unconditionally.
duration
- the duration of the animation in millisecondselement
- the element that visually bounds the entire animationpublic void run(int duration, double startTime)
This is equivalent to run(duration, startTime, null)
.
duration
- the duration of the animation in millisecondsstartTime
- the synchronized start time in millisecondsrun(int, double, Element)
public void run(int duration, double startTime, Element element)
If the element is not null
, the onUpdate(double)
method might be called only if the element may be visible (generally left
at the appreciation of the browser). Otherwise, it will be called
unconditionally.
duration
- the duration of the animation in millisecondsstartTime
- the synchronized start time in millisecondselement
- the element that visually bounds the entire animationpublic boolean isRunning()
protected double interpolate(double progress)
Animation
, the return value of this method can be
less than 0.0 or greater than 1.0.progress
- the linear progress, between 0.0 and 1.0protected void onCancel()
onComplete()
only if the
animation has actually started running.protected void onComplete()
protected void onStart()
protected abstract void onUpdate(double progress)
interpolate(double)
method to provide a wider range
of values). There is no guarantee that onUpdate(double)
is called
with 0.0 or 1.0.
If you need to perform setup or tear down procedures, you can override
onStart()
and onComplete()
.progress
- a double, normally between 0.0 and 1.0 (inclusive)Copyright © 2018. All rights reserved.