Skip to content

PlAnimateSlide

Content travelling in from one edge. The default distance is the element's own size, so it starts exactly out of frame and is never half drawn somewhere it does not belong.

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

<div className="overflow-hidden">
  <PlAnimateSlide from="right">
    <PlCard title="New message">Ada replied to your review.</PlCard>
  </PlAnimateSlide>
</div>;
dart
import 'package:plass_ui/plass_ui.dart';

const ClipRect(
  child: PlAnimateSlide(
    from: PlassSide.right,
    child: PlCard(title: Text('New message'), child: Text('Ada replied to your review.')),
  ),
);

Props

PropTypeDefaultDescription
mode'in' | 'out''in'Whether the content slides in or slides away. out leaves by the same edge it would have come from
fromshared'top' | 'right' | 'bottom' | 'left''bottom'Which edge it travels from. Physical, as it is everywhere in the library: a panel coming down from the top comes from the top in every writing direction
distancenumber | string'100%'How far it travels — a CSS length, or a number in pixels. '100%' is the element's own width or height, which is what makes it appear from behind its own edge
fadebooleantrueFades in as it slides
durationsharednumber360How 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 slides in or slides away. exit leaves by the same edge it would have come from. enter/exit rather than in/out, because in is a reserved word in Dart
fromsharedPlassSidePlassSide.bottomWhich edge it travels from. Physical, as it is everywhere in the library: a panel coming down from the top comes from the top in every writing direction
distancedouble?its own sizeHow far it travels, in logical pixels. null is the widget's own width or height, which is what makes it appear from behind its own edge
fadebooltrueFades in as it slides
durationsharedDurationDuration(milliseconds: 360)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 travels

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

distance is a double? in logical pixels, and null — the default — is the widget's own width or height. There is no CSS length to write: a fraction of a widget's own size is what FractionalTranslation already means, and that is what the widget uses when no distance is given.

from is physicaltop, right, bottom, left — as PlassSide is everywhere in the library. A panel coming down from the top comes from the top in every writing direction.

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

from

Four edges, and mode="out" leaves by whichever one it would have arrived from.

React

distance

A number is pixels, a string is any CSS length. '100%' is the element's own width or height — put it in a box with overflow: hidden and the effect is a panel appearing from behind that box's edge. Short distances are a different gesture: a nudge that says something changed, rather than an entrance.

React

Accessibility

  • Under prefers-reduced-motion the animation is dropped entirely and the content is simply there.
  • Nothing on the page reflows while it runs. This is a translate rather than a change of layout, so what is around the element does not move.
  • A slide that starts out of frame will overflow whatever is holding it unless that box clips. Clip it, or the page grows a scrollbar for the length of the animation.
  • For a much shorter travel across a list of things, one after another, use PlAnimateAppear — the stagger is what makes that effect, and a slide per child would leave you writing the delays yourself.
  • When the platform has animations turned off (MediaQuery.disableAnimations) the effect is dropped entirely and the content is simply there.
  • Nothing around it is laid out again while it runs. This moves the widget rather than changing the layout.
  • A slide that starts out of frame will overflow whatever is holding it unless that box clips. Wrap it in a ClipRect.
  • For a much shorter travel across a list of things, one after another, use PlAnimateAppear.

Differences from the React build

ReactFlutterWhy
distance as a CSS length or a numberdouble?, null is its own sizeA fraction of a widget's own size is what FractionalTranslation already means, so there is nothing to spell as a string.
mode="in" | "out"PlassAnimateMode.enter / .exitin is a reserved word in Dart.
overflow: hidden on a wrapperClipRectThe framework's own name for the same clip.
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