ScaleIn

Scroll-reveal animation that scales content from an initial scale to full size when entering the viewport.

Preview/Playground

Created by
Creator
Vipin

Scale In - Default

Scale In - Enhanced

Scale In - Enhanced with props

Astro Astro
import ScaleIn from '@astroanimate/core/ScaleIn';

<ScaleIn enhance={true}>
  <h1>Your content here</h1>
</ScaleIn>

Installation

bash
npm install @astroanimate/core

Usage

import ScaleIn from '@astroanimate/core/ScaleIn';

<ScaleIn enhance={true}>
  <h1>Your content here</h1>
</ScaleIn>

Applies scale animation when element scrolls into view.

Props

Prop Type Default Description
enhance boolean false Opt-in to JS enhancement (Scroll Reveal). If false, renders visible immediately with no animation
initialScale number 0.9 Initial scale value to start from
duration number 600 Duration of animation in milliseconds
delay number 0 Delay before animation starts in milliseconds
easing string cubic-bezier(0.34, 1.56, 0.64, 1) CSS easing function
once boolean true Whether animation should only play once. If false, reverses when scrolling out
margin string 0px 0px -10% 0px IntersectionObserver margin
class string - Optional CSS class for the root element
as ScaleInTag div HTML tag to use for the root element (div, section, article, aside, main, header, footer, nav, span, p, h1-h6, li, ul, ol, a, button)

Use When

  • Content should animate when scrolling into view
  • Need scale-based entrance animations
  • Want progressive disclosure of sections

Avoid When

  • Content must be visible immediately without JS
  • Need complex multi-stage animations
  • Require continuous looping animations

Accessibility

ScaleIn is built with accessibility as a priority:

  • Respects prefers-reduced-motion media query
  • Disables all animations when user prefers reduced motion
  • Renders visible by default without JS

Performance

  • Uses IntersectionObserver for efficient scroll detection
  • WeakMap prevents memory leaks with cleanup on DOM removal
  • MutationObserver handles element removal from DOM

Credits