JavaEE Training Note - Day 15
Today’s topic is some component library used together with ReactJS. The React Motion is a UX improvement library named React Motion, which provides supports to transition animation.
React Motion
React Motion provides three component and an unified interpolation function to create transition effects from one state to another.
spring
function
The unified interpolation function is named spring
. As it name indicates,
the function is just to crate interpolation based on the physical behavior
of a real world spring. The library choose spring as its model to create its
interpolation function is based on the fact that by applying simple physics
rules to restrict the motion of the spring
controlled variable, the
state can just behavored as a spring. Any state is a possible initial state
and no more timing function is required. Besides, no more ugly breaks will
appear when previous action is unfinished while a new action is applied.
Even though the transition function is unified, there are still two parameters to describe the physical attributes, which are stiffness and damping. The first one describes the power of the spring and generally, the larger stiffness, the less time required for certain animation. The second one, damping describes the slowing down effects for a certain animation. The smaller the damping is, the larger time required to finish a certain animation. Especially, when the stiffness is set to 0, the value will not change, while when the damping is set to 0, the value will never stop changing, but keep going up and down around a certain value.
Based on this unified interpolation function, React Motion provides 3 component to apply then to other React components.
<Motion />
The <Motion />
component provides simple effects to a single components.
By wrapping a target component into the <Motion />
component, a interpolation
value is provided to the content and can be used to apply to styles.
A simple example is shown as follows:
<StaggeredMotion />
The <StaggeredMotion />
component is to provide a series of interpolated value and these values are
interconnected. This can create a effects like a serial objects are linked by a single string.
A section of code is shown as follows:
<TransitionMotion />
The <TransitionMotion />
component is a state based transition, which generally
create transition effect for a component to be mounted and to be unmounted.
The following code shows the usage of fading in and sliding in effects.
|
|