Skip to content

PlAnimateGrow

Content unfolding from a point. It starts close to its final size and can be anchored to any edge, so it reads as something opening out of the thing beside it.

React
tsx
import { PlAnimateGrow } from 'plass-ui';

<PlAnimateGrow origin="top">
  <PlBox>Sort, group and column visibility.</PlBox>
</PlAnimateGrow>;
dart
import 'package:plass_ui/plass_ui.dart';

const PlAnimateGrow(
  origin: Alignment.topCenter,
  child: PlBox(child: Text('Sort, group and column visibility.')),
);

Props

PropTypeDefaultDescription
mode'in' | 'out''in'Whether the content unfolds or folds away. out is the same keyframe run backwards
fromnumber0.8The scale it starts from, as a multiple of its final size. Above 1 it settles down onto the page instead of up out of it
originstring'center'Which point stays put while the rest moves — any CSS transform-origin. top unfolds downwards, bottom left out of a corner
fadebooleantrueFades in as it grows. Turn it off for something already on the page that is only changing size
durationsharednumber320How long one run takes, in milliseconds. A number, never a CSS string
delaysharednumber0How long before it starts, in milliseconds
easingsharedstringthe house curveThe easing curve, written the way CSS writes it
repeatsharednumber | 'infinite'1How many times it runs. 'infinite' rather than Infinity, because that word is what reaches CSS
alternatesharedbooleanfalseRuns every other pass backwards, so a repeat returns instead of jumping
pausedsharedbooleanfalseHolds the animation where it is
triggershared'mount' | 'visible' | 'hover' | 'manual''mount'What starts it: mount as soon as it is on the page, visible when it is scrolled into view, hover while the pointer or focus is on it, manual only when play says so
playsharedbooleanRuns it when trigger is manual. Each false → true starts it over
oncesharedbooleantrueWith trigger="visible", whether it runs only the first time. Off, it runs again every time the element comes back into view
thresholdsharednumber0.2With trigger="visible", how much of the element has to be on screen before it counts as visible, from 0 to 1
timelineshared'auto' | 'view''auto'What advances the animation: the clock, or the reader's scroll position. view ignores duration, delay, repeat and trigger, and runs against range instead
rangesharedstring'entry 0% cover 45%'As CSS writes an animation-range. Only read when timeline is view
staggersharednumber0Milliseconds added to each child's delay. 0 plays the box itself; anything else moves the effect onto the children and takes it off the box
durationStepsharednumber0Milliseconds added to each child's duration. Negative is allowed; floored at 0
reversesharedbooleanfalseRuns the set from the last child to the first. Only the order turns round; each child still plays forwards
renderReactElement | (props, state) => ReactElementRenders something other than a <div>
PropTypeDefaultDescription
modePlassAnimateModePlassAnimateMode.enterWhether the content unfolds or folds away. enter/exit rather than in/out, because in is a reserved word in Dart
fromdouble0.8The scale it starts from, as a multiple of its final size. Above 1 it settles down onto the page instead of up out of it
originAlignmentAlignment.centerWhich point stays put while the rest moves. An Alignment rather than a CSS string: topCenter unfolds downwards, bottomLeft out of a corner
fadebooltrueFades in as it grows. Turn it off for something already on the page that is only changing size
durationsharedDurationDuration(milliseconds: 320)How long one run takes, in milliseconds. A number, never a CSS string
delaysharedDurationDuration.zeroHow long before it starts, in milliseconds
curvesharedCurve?the house curveThe easing curve, written the way CSS writes it
repeatsharedint?1How many times it runs. null is what never stops: there is no 'infinite' to write, and -1 would be a sentinel a caller has to look up
alternatesharedboolfalseRuns every other pass backwards, so a repeat returns instead of jumping
pausedsharedboolfalseHolds the animation where it is
triggersharedPlassAnimateTriggerPlassAnimateTrigger.mountWhat starts it: mount as soon as it is on the page, visible when it is scrolled into view, hover while the pointer or focus is on it, manual only when play says so
playsharedboolfalseRuns it when trigger is manual. Each false → true starts it over
oncesharedbooltrueWith trigger="visible", whether it runs only the first time. Off, it runs again every time the element comes back into view
thresholdshareddouble0.2With trigger="visible", how much of the element has to be on screen before it counts as visible, from 0 to 1
child * WidgetWhat unfolds

Every native <div> attribute passes straight through, and render swaps the element for another one.

origin is an Alignment rather than a CSS transform-origin string, because the framework already has the type. duration and delay are Durations, curve is a Curve, and repeat is an int? where null never stops.

The ten shared settings — duration, delay, easing, repeat, alternate, paused, trigger, play, once, threshold — are the same on every PlAnimate* component. The four trigger values are shown on the PlAnimateFade page. timeline="view" and range are there too, and hand the effect to the reader's scroll position instead of the clock.

Three more move the effect off the box and onto the things inside it: stagger holds each child back by its position, durationStep gives each one a longer or shorter run than the last, and reverse starts from the end of the set. They are on all six single-keyframe effects and are shown on the PlAnimateFade page.

Examples

origin

The anchor is the whole difference between this and PlAnimateZoom. A panel that unfolds from top is a panel coming out of the control above it; one that unfolds from bottom right is coming out of the corner it is pinned to. Anything anchored to the middle is a zoom, and there is only one component for that idea.

React

from

Above 1 it arrives oversized and settles back. Short travel is what keeps it safe on glass: a sheet growing from 0.8 stays recognisably the same sheet the whole way, and the blur behind it is never asked to resolve a surface a fifth of the size it is about to be.

React

Opening a panel

The common use, and the one the defaults were chosen for: origin="top", a short distance, a quick duration. The panel unfolds from the control that opened it rather than appearing beside it.

React

Accessibility

  • Under prefers-reduced-motion the animation is dropped entirely and the content is simply there.
  • The wrapper adds no role and no label. It is a <div> around content that already says what it is.
  • Scaling resamples whatever is inside, so keep the travel short over text — that is what from defaults to 0.8 for. Long travel belongs on a shape, an icon or a picture.
  • This is a wrapper, not a disclosure. Mounting and unmounting the content is the caller's job, and so is whatever aria-expanded belongs on the control that did it.
  • When the platform has animations turned off (MediaQuery.disableAnimations) the effect is dropped entirely and the content is simply there.
  • The widget adds no semantics of its own. It is a Transform around content that already says what it is.
  • Scaling resamples whatever is inside, so keep the travel short over text — that is what from defaults to 0.8 for. Long travel belongs on a shape, an icon or a picture.
  • This is a wrapper, not a disclosure. Adding and removing the content is the caller's job, and so is whatever a screen reader should be told about it.

Differences from the React build

ReactFlutterWhy
origin as a CSS transform-origin stringAlignmentThe framework already has the type, and Alignment.topCenter reads better than 'top'.
fade draws an always-present opacity layerno Opacity widget at all when fade is offOne fewer layer to composite, and nothing in the tree claiming to be doing something it is not.
mode="in" | "out"PlassAnimateMode.enter / .exitin is a reserved word in Dart.
renderFlutter has no polymorphic element.
duration, delay in millisecondsDurationThe framework already has the type.
easing as a CSS stringcurve, a CurveDart's own name for the same thing.
repeat: number | 'infinite'int?, null never stopsThere is no 'infinite' to write, and -1 would be a sentinel a caller has to look up.
trigger="visible" via IntersectionObserverwatches the nearest ScrollableThere is no observer here; with no scrollable above it there is nothing to watch, so it runs.
prefers-reduced-motionMediaQuery.disableAnimationsThe platform's own signal.
stagger, durationStep, reverseThe React build writes the effect onto the children themselves, so the caller's own layout is untouched. Flutter has no stylesheet to lay a set out with, so a staggered effect would have to own the row or the column as well — which is what PlAnimateAppear is, and six more of it would be six more of it.
timeline="view"animation-timeline is a CSS property with no counterpart here. A scroll-linked effect in Flutter is an AnimationController driven from a ScrollPosition, which is an application's own wiring rather than something a widget takes as a prop.
className, styleThere is no class list and no style attribute to pass through.

Released under the MIT License