Class Grow
Grow transitions animate the element's scale with a configurable origin point and optional fade. The default scales to 1.5x from center with a fade.
Note: Because Grow uses the CSS transform property,
it cannot be combined with Slide on the same element — the last one
applied will overwrite the other's transform value.
Usage:
// Grow to 2x from top-left corner
panel.addTransition(new Grow()
.setScale(2.0f)
.setOrigin(Origin.LEFT, Origin.TOP));
panel.transitionForward();
// Shrink to nothing from center
panel.addTransition(new Grow().setScale(0f));
panel.transitionForward();
- Since:
- 2026
- Version:
- 1.0
- Author:
- Marvin P. Warble Jr.
- See Also:
-
Constructor Summary
ConstructorsConstructorDescriptionGrow()Constructs a Grow transition that scales to 1.5x from center with fade. -
Method Summary
Modifier and TypeMethodDescriptionvoidapplyEndState(CssStyle style) Applies the transition's end state to the given style.Returns the horizontal transform origin.Returns the vertical transform origin.floatgetScale()Returns the target scale factor.protected String[]Returns the CSS property names that this transition animates.booleanReturns whether the grow includes a fade.voidrestoreOriginalState(CssStyle style, CssStyle snapshot) Restores previously saved property values to the given style.Sets the transform origin for the scale effect.setScale(float scale) Sets the target scale factor.setWithFade(boolean withFade) Sets whether the grow includes a simultaneous fade.voidsnapshotCurrentState(CssStyle current, CssStyle snapshot) Saves the current values of the transition's properties from the element's style.Methods inherited from class com.oorian.css.transitions.Transition
buildTransitionValue, buildTransitionValue, getDurationMs, getTimingFunction, setDuration, setSpeed
-
Constructor Details
-
Grow
public Grow()Constructs a Grow transition that scales to 1.5x from center with fade.
-
-
Method Details
-
setScale
Sets the target scale factor.- Parameters:
scale- the scale factor (e.g., 1.5 for 150%, 0 for shrink to nothing)- Returns:
- this Grow for method chaining
-
setOrigin
Sets the transform origin for the scale effect.- Parameters:
originX- the horizontal origin (LEFT, CENTER, or RIGHT)originY- the vertical origin (TOP, CENTER, or BOTTOM)- Returns:
- this Grow for method chaining
-
setWithFade
Sets whether the grow includes a simultaneous fade.- Parameters:
withFade- true to fade during the scale, false for scale only- Returns:
- this Grow for method chaining
-
getScale
public float getScale()Returns the target scale factor.- Returns:
- the scale factor
-
getOriginX
Returns the horizontal transform origin.- Returns:
- the horizontal origin
-
getOriginY
Returns the vertical transform origin.- Returns:
- the vertical origin
-
isWithFade
public boolean isWithFade()Returns whether the grow includes a fade.- Returns:
- true if fading during scale
-
getTransitionProperties
Returns the CSS property names that this transition animates.Subclasses return the CSS properties they modify (e.g.,
"opacity","transform","max-height"). These are used to build the CSStransitionshorthand.- Specified by:
getTransitionPropertiesin classTransition- Returns:
- an array of CSS property names
-
applyEndState
Applies the transition's end state to the given style.This method sets the CSS property values that represent the final state of the transition. For example, a fade-out sets
opacity: 0.- Specified by:
applyEndStatein classTransition- Parameters:
style- the CssStyle to apply end-state values to
-
snapshotCurrentState
Saves the current values of the transition's properties from the element's style.Before a transition plays forward, the current property values are saved so they can be restored when playing in reverse. If a property has no current value, the subclass should save a sensible default (e.g.,
"1"for opacity).- Specified by:
snapshotCurrentStatein classTransition- Parameters:
current- the element's current CssStyle to read values fromsnapshot- the CssStyle to save values into
-
restoreOriginalState
Restores previously saved property values to the given style.This method copies values from the snapshot back to the element's style, causing the browser to animate back to the original state.
- Specified by:
restoreOriginalStatein classTransition- Parameters:
style- the CssStyle to restore values tosnapshot- the CssStyle containing previously saved values
-