TransformationVariableSpec
public class TransformationVariableSpec(
/**
* The value this variable will have when the item's bottom edge is above the top transformation
* zone, usually this happens when it is (or is about to be) partially outside of the screen on
* the top side.
*/
@FloatRange(from = 0.0, to = 1.0) public val topValue: Float,
/**
* The value this variable will have when the item is not in either transformation zone, and is
* in the "center" of the screen, i.e. the top edge is above the bottom transformation zone, and
* the bottom edge is below the top transformation zone.
*/
@FloatRange(from = 0.0, to = 1.0) public val targetValue: Float = 1f,
/**
* The value this variable will have when the item's top edge is below the bottom transformation
* zone, usually this happens when it is (or is about to be) partially outside of the screen on
* the bottom side.
*/
@FloatRange(from = 0.0, to = 1.0) public val bottomValue: Float = topValue,
/**
* Defines how far into the transition area the transformation zone starts. For example, a value
* of 0.5f means that when the item enters the screen from the top, this variable will not start
* to transform until the bottom of the item reaches the middle point of the transition area.
* Should be less than [transformationZoneExitFraction].
*
* Visually, the top transition area and top transformation zone can be visualized as:
* ```
* ˅ --------------------- <-- Top of the screen
* | | |
* | |-------------------| <- Enter fraction, item moving down
* TA | | TZ | <- Transformation Zone
* | |-------------------| <- Exit fraction, item moving down
* | | |
* ^ |-------------------|
* ```
*
* On the bottom, it is the same mirrored vertically (exit fraction is above enter fraction). It
* is also worth noting that in the bottom, it is the top of the item that triggers starting and
* ending transformations.
*/
@FloatRange(from = 0.0, to = 1.0) public val transformationZoneEnterFraction: Float = 0f,
/**
* Defines how far into the transition area the transformation zone ends. For example, a value
* of 0.5f means that when the item is moving down, its bottom edge needs to reach the middle
* point of the transition area for this variable to reach it's maximum/target value. Should be
* greater than [transformationZoneEnterFraction].
*
* See also [transformationZoneEnterFraction]
*/
@FloatRange(from = 0.0, to = 1.0) public val transformationZoneExitFraction: Float = 1f,
)
This class represents the configuration parameters for one variable that changes as the item
moves on the screen and will be used to apply the corresponding transformation - for example:
container alpha. When an item enters from the top of the screen the value of this variable will
be topValue
. As the item's bottom edge moves through the top transformation zone (inside the
top transition area), this variable will change from topValue
to target value (target value is
the nominal value of this variable, with no transformation applied, such as 1f for alpha). When
the item's top edge moves through the bottom transformation zone (inside the bottom transition
area), this variable will change from the target value into bottomValue
, and keep that value
until it leaves the screen. The same process happens in reverse, entering from the bottom of the
screen and leaving at the top.
Functions
public fun copy(
topValue: Float = this.topValue,
targetValue: Float = this.targetValue,
bottomValue: Float = this.bottomValue,
transformationZoneEnterFraction: Float = this.transformationZoneEnterFraction,
transformationZoneExitFraction: Float = this.transformationZoneExitFraction,
): TransformationVariableSpec
Returns a copy of the TransformationVariableSpec.