Class FadeTransition
- java.lang.Object
-
- ej.navigation.transition.FadeTransition
-
- All Implemented Interfaces:
Transition
public class FadeTransition extends Object implements Transition
A transition that fades the incoming content in over the outgoing one.Each frame draws the incoming content in place, at an opacity that follows an easing
Function(a quadratic ease-out by default) from fully transparent to fully opaque. The outgoing content is the frame left on the display, so what the blend dissolves from is simply what was already there.Fading needs the incoming content as an image, so this transition depends on the snapshots: when an application disables them through
Transition.SNAPSHOTS_CONSTANT, there is nothing to blend andgetDuration()reports0, turning the fade into an instant page change.- Since:
- 0.2.0
-
-
Field Summary
-
Fields inherited from interface ej.navigation.transition.Transition
DEFAULT_DURATION_MILLIS, IMMEDIATE, SNAPSHOTS_CONSTANT
-
-
Constructor Summary
Constructors Constructor Description FadeTransition()Creates a fade with the default duration and easing.FadeTransition(int duration)Creates a fade with the given duration and the default easing.FadeTransition(int duration, Function easing)Creates a fade with the given duration and easing.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description intgetDuration()Returns how long this transition lasts, in milliseconds.voidrender(GraphicsContext g, TransitionContext context, float progress)Draws one frame of this transition.voidstart(TransitionContext context)Prepares this transition for the page change described by the given context.
-
-
-
Constructor Detail
-
FadeTransition
public FadeTransition()
Creates a fade with the default duration and easing.
-
FadeTransition
public FadeTransition(int duration)
Creates a fade with the given duration and the default easing.- Parameters:
duration- the fade duration, in milliseconds; must be strictly positive.- Throws:
IllegalArgumentException- if the given duration is not strictly positive.
-
FadeTransition
public FadeTransition(int duration, Function easing)Creates a fade with the given duration and easing.- Parameters:
duration- the fade duration, in milliseconds; must be strictly positive.easing- the function shaping the opacity over the duration.- Throws:
IllegalArgumentException- if the given duration is not strictly positive.- Since:
- 2.0.0
-
-
Method Detail
-
getDuration
public int getDuration()
Description copied from interface:TransitionReturns how long this transition lasts, in milliseconds.A duration of
0or less makes the page change instant: the navigator shows the incoming content immediately, without starting this transition and without drawing a single frame.- Specified by:
getDurationin interfaceTransition- Returns:
- the duration in milliseconds.
-
start
public void start(TransitionContext context)
Description copied from interface:TransitionPrepares this transition for the page change described by the given context.Called once per navigation, before the first frame, and only when
Transition.getDuration()is strictly positive. The incoming content is already captured, so an implementation may read the content area size and the navigation kind here. Nothing is drawn during this call.- Specified by:
startin interfaceTransition- Parameters:
context- the context of the page change about to be animated.
-
render
public void render(GraphicsContext g, TransitionContext context, float progress)
Description copied from interface:TransitionDraws one frame of this transition.The given graphics context is translated and clipped to the content area, and already holds the pixels of the previous frame — the outgoing content. An implementation draws the incoming content over them through the given context.
- Specified by:
renderin interfaceTransition- Parameters:
g- the graphics context to draw the frame with, translated and clipped to the content area.context- the context of the page change being animated.progress- how far the transition has advanced: the elapsed time divided by the duration, at least0and strictly less than1.
-
-