Ripple

January 9, 2019 ยท View on GitHub

Adds a touch ripple effect to an element.

Buttons contain a ripple element by default. This component lets you add a ripple to other components.

Main features

  • Set duration
  • Set start and end opacity
  • Set start and end scale
  • Set color
  • Customize animation
  • Center ripple
  • Transition ripple to persistent color fill
  • Multiple simultaneous ripples
  • Callback function when ripple has started and finished

Usage

Options

Ripple specific options

ParameterRequiredTypeDefaultDescription
animationTimingFunctionoptionalString"ease-out"Name of animation function: "ease-in-out" or "cubic-bezier(0.1, 0.7, 1.0, 0.1)"
centeroptionalBooleanfalseSet to true to start the ripple from the center
disabledoptionalBooleanfalseSet to true to disable ripples
durationoptionalNumber1 / opacityDecayVelocity * 0.2The animation duration in seconds
startoptionalFunction(e: Event) => voidCallback function just before the ripple starts; see Callback functions
endoptionalFunction(e: AnimationEvent) => voidCallback function when the ripple has ended; see Callback functions
endOpacityoptionalNumber0.0Opacity at the end of the ripple animation
endScaleoptionalNumber2.0Scale at the end of the ripple animation
multioptionalBooleanfalseSet to true to enable multiple simultaneous ripples, instead of one after the other
opacityDecayVelocityoptionalNumber0.4Velocity of decrease of opacity
persistentoptionalBooleanfalseSet to true to keep the ripple at the end of the animation to make a persistent color fill
startOpacityoptionalNumber0.2Opacity at the start of the ripple animation
startScaleoptionalNumber0.1Scale at the start of the ripple animation
targetoptionalHTML Elementthe ripple's parent node elementThe target defines which element responds to tap
unconstrainedoptionalBooleanfalseSet to true to make the ripple shape no longer bound to the target element

Common component options

ParameterRequiredTypeDefaultDescription
classNameoptionalStringExtra CSS class appended to pe-ripple
elementoptionalString"div"HTML element tag
idoptionalStringHTML element id
styleoptionalObjectFor setting simple style attributes
toneoptionalString: "dark" or "light"Renders the component light on dark (sets class pe-dark-tone); use "light" to locally inverse (sets class pe-light-tone)

Callback functions

FunctionTypes
start(MouseEvent) -> undefined
end(AnimationEvent) -> undefined

CSS classes