Class SlideTransition
- java.lang.Object
-
- ej.navigation.transition.SlideTransition
-
- All Implemented Interfaces:
Transition
public class SlideTransition extends Object implements Transition
A transition that slides the incoming content in from one edge of the content area.The outgoing content does not move: it is the frame left on the display, and a frame can only draw over it. The incoming content starts fully off the direction's edge and travels to its place, the travel being shaped by an easing
Function(a quadratic ease-out by default).On a
TransitionContext.BACKnavigation the direction is mirrored by default, so going back undoes visually what going forward did. A constructor flag turns that off for an application that wants one fixed direction whatever the navigation.- Since:
- 0.2.0
-
-
Field Summary
Fields Modifier and Type Field Description static intBOTTOM_TO_TOPDirection where the incoming content enters from the bottom edge.static intLEFT_TO_RIGHTDirection where the incoming content enters from the left edge.static intRIGHT_TO_LEFTDirection where the incoming content enters from the right edge.static intTOP_TO_BOTTOMDirection where the incoming content enters from the top edge.-
Fields inherited from interface ej.navigation.transition.Transition
DEFAULT_DURATION_MILLIS, IMMEDIATE, SNAPSHOTS_CONSTANT
-
-
Constructor Summary
Constructors Constructor Description SlideTransition()Creates a right-to-left slide with the default duration and easing, mirrored on back navigations.SlideTransition(int direction)Creates a slide in the given direction with the default duration and easing, mirrored on back navigations.SlideTransition(int direction, int duration)Creates a slide in the given direction with the given duration and the default easing, mirrored on back navigations.SlideTransition(int direction, int duration, Function easing)Creates a slide in the given direction with the given duration and easing, mirrored on back navigations.SlideTransition(int direction, int duration, Function easing, boolean mirrorOnBack)Creates a slide in the given direction with the given duration and easing, mirroring the direction on back navigations only if asked to.
-
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.
-
-
-
Field Detail
-
RIGHT_TO_LEFT
public static final int RIGHT_TO_LEFT
Direction where the incoming content enters from the right edge.- See Also:
- Constant Field Values
-
LEFT_TO_RIGHT
public static final int LEFT_TO_RIGHT
Direction where the incoming content enters from the left edge.- See Also:
- Constant Field Values
-
BOTTOM_TO_TOP
public static final int BOTTOM_TO_TOP
Direction where the incoming content enters from the bottom edge.- Since:
- 2.0.0
- See Also:
- Constant Field Values
-
TOP_TO_BOTTOM
public static final int TOP_TO_BOTTOM
Direction where the incoming content enters from the top edge.- Since:
- 2.0.0
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
SlideTransition
public SlideTransition()
Creates a right-to-left slide with the default duration and easing, mirrored on back navigations.
-
SlideTransition
public SlideTransition(int direction)
Creates a slide in the given direction with the default duration and easing, mirrored on back navigations.- Parameters:
direction-RIGHT_TO_LEFT,LEFT_TO_RIGHT,BOTTOM_TO_TOP, orTOP_TO_BOTTOM.- Throws:
IllegalArgumentException- if the given direction is none of the four.
-
SlideTransition
public SlideTransition(int direction, int duration)Creates a slide in the given direction with the given duration and the default easing, mirrored on back navigations.- Parameters:
direction-RIGHT_TO_LEFT,LEFT_TO_RIGHT,BOTTOM_TO_TOP, orTOP_TO_BOTTOM.duration- the slide duration, in milliseconds; must be strictly positive.- Throws:
IllegalArgumentException- if the given direction is none of the four, or if the given duration is not strictly positive.
-
SlideTransition
public SlideTransition(int direction, int duration, Function easing)Creates a slide in the given direction with the given duration and easing, mirrored on back navigations.- Parameters:
direction-RIGHT_TO_LEFT,LEFT_TO_RIGHT,BOTTOM_TO_TOP, orTOP_TO_BOTTOM.duration- the slide duration, in milliseconds; must be strictly positive.easing- the function shaping the travel over the duration.- Throws:
IllegalArgumentException- if the given direction is none of the four, or if the given duration is not strictly positive.- Since:
- 2.0.0
-
SlideTransition
public SlideTransition(int direction, int duration, Function easing, boolean mirrorOnBack)Creates a slide in the given direction with the given duration and easing, mirroring the direction on back navigations only if asked to.- Parameters:
direction-RIGHT_TO_LEFT,LEFT_TO_RIGHT,BOTTOM_TO_TOP, orTOP_TO_BOTTOM.duration- the slide duration, in milliseconds; must be strictly positive.easing- the function shaping the travel over the duration.mirrorOnBack-trueto mirror the direction on aTransitionContext.BACKnavigation,falseto always slide in the given direction.- Throws:
IllegalArgumentException- if the given direction is none of the four, or 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.
-
-