Scroll Animation Framework Logo

Scroll Animation Framework

A modern, performance-focused, and flexible JavaScript framework for implementing scroll-based animations in web pages with seamless integration with the popular Animate.css library.

✨ Core Features

  • Animate.css Integration: Full compatibility with the popular Animate.css library
  • Intersection Observer API: Modern and performant scroll detection
  • Automatic Element Detection: Smart element detection based on CSS classes
  • Stagger Animations: Sequential animations for elements within containers
  • Accessibility Support: Automatic adaptation to reduced motion preferences
  • Performance Monitoring: Real-time performance metrics
  • Debug Mode: Detailed logging to facilitate development process (CTRL + D)

πŸš€ Installation and Getting Started

Requirements

1. Include Animate.css library on your page:

CDN

<link rel= "stylesheet" href= "https://cdnjs.cloudflare.com/ajax/libs/animate.css/4.1.1/animate.min.css" >

Local

<link rel= "stylesheet" href= "../dist/animate-css/animate.min.css" >

2. Include the framework file:

<script src= "../dist/js/scroll-animation-framework.min.js" ></script>

Auto-initialization

The framework starts automatically by default. To disable:

<script>
window.SCROLL_ANIMATOR_AUTO_INIT = false;
</script>

Manual Initialization

const scrollAnimator = new ScrollAnimationFramework ({
debug: true,
defaultAnimation: 'fadeInUp',
staggerDelay: 200
});

πŸ“– Usage Methods

Data Attribute Method

<!-- Simple animation --> <div data-scroll-animate="fadeInUp">Hello World!</div> <!-- With detailed settings --> <div data-scroll-animate="bounceIn" data-scroll-duration="1.5s" data-scroll-delay="200">      Detailed Animation </div> <!-- With all settings --> <div data-scroll-animate="slideInLeft" data-scroll-duration="2s" data-scroll-delay="500" data-scroll-callback="myCallback">      Fully Controlled Animation </div>

Multiple Elements Usage (Container)

<!-- Multiple animations with container --> <div data-scroll-container data-scroll-animate="fadeInUp" data-scroll-stagger="200">      <div class="item">Element 1</div>      <div class="item">Element 2</div>      <div class="item">Element 3</div>      <div class="item">Element 4</div> </div> <!-- With different animations --> <div data-scroll-container data-scroll-animate="bounceIn" data-scroll-duration="1.2s" data-scroll-stagger="150">      <div class="card">Card 1</div>      <div class="card">Card 2</div>      <div class="card">Card 3</div> </div>

Class-Based Auto Detection

<div class="card">This gets automatic slide-up animation</div> <div class="hero-title">This gets automatic fade animation</div> <div class="feature-box">This gets automatic slide-left animation</div> <button class="button">This gets automatic bounce animation</button>

Programmatic Usage with JavaScript

// Adding element scrollAnimator.addElement(document.querySelector('#myElement'), {      animation: 'zoomIn',      duration: '1.5s',      delay: 300 }); // Triggering animation scrollAnimator.triggerAnimation('.my-selector', {      animation: 'pulse',      duration: '2s' }); // Resetting all animations scrollAnimator.resetAllAnimations(); // Updating configuration scrollAnimator.updateConfig({      defaultAnimation: 'slideInRight',      staggerDelay: 200 });

Advanced Usage Examples

<!-- With callback function --> <div data-scroll-animate="jackInTheBox" data-scroll-callback="elementAnimated">      Element with Callback </div> <!-- With different threshold --> <div data-scroll-animate="rotateIn" data-scroll-threshold="0.8">      Late Triggered Element </div> <!-- Combination example --> <section data-scroll-container data-scroll-animate="fadeInUp" data-scroll-stagger="100">      <h2 data-scroll-animate="slideInDown" data-scroll-delay="0">Title</h2>      <p data-scroll-animate="fadeIn" data-scroll-delay="200">Description</p>      <div class="cards">           <div class="card">Card 1</div>           <div class="card">Card 2</div>           <div class="card">Card 3</div>      </div> </section>

Configuration Options

// Framework initialization const scrollAnimator = new ScrollAnimationFramework({      // Basic settings      defaultAnimation: 'fadeInUp',      defaultDuration: '1s',      staggerDelay: 150,      // Debug      debug: true,      performanceMonitor: true, // Callbacks onElementAnimated: (element, config) => {      console.log('Element animation completed:', element); }, onAllAnimationsComplete: () => {      console.log('All animations completed!'); } });

Event Listeners

// When element animation completes document.addEventListener('scrollAnimationComplete', (event) => {      const { element, config } = event.detail;      console.log('Animation completed:', element); }); // Custom callback function window.myCallback = function(element) {      console.log('Custom callback executed:', element);      // Additional operations... };

πŸ’‘ Tips

  1. Performance: Use data-scroll-container for multiple elements
  2. Accessibility: Framework automatically supports prefers-reduced-motion
  3. Debug: Use debug: true during development
  4. Stagger: Use stagger effects for multiple elements to add visual richness
  5. Duration: Use 0.3-0.8s for fast animations, 1-2s for dramatic effects

πŸ“‹ Animation Categories and List

🎯 Attention Seekers

  • bounce
  • flash
  • pulse
  • rubberBand
  • shakeX
  • shakeY
  • headShake
  • swing
  • tada
  • wobble
  • jello
  • heartBeat

⬅️ Back Entrances

  • backInDown
  • backInLeft
  • backInRight
  • backInUp

➑️ Back Exits

  • backOutDown
  • backOutLeft
  • backOutRight
  • backOutUp

πŸ€ Bouncing Entrances

  • bounceIn
  • bounceInDown
  • bounceInLeft
  • bounceInRight
  • bounceInUp

πŸ€ Bouncing Exits

  • bounceOut
  • bounceOutDown
  • bounceOutLeft
  • bounceOutRight
  • bounceOutUp

🌫️ Fading Entrances

  • fadeIn
  • fadeInDown
  • fadeInDownBig
  • fadeInLeft
  • fadeInLeftBig
  • fadeInRight
  • fadeInRightBig
  • fadeInUp
  • fadeInUpBig
  • fadeInTopLeft
  • fadeInTopRight
  • fadeInBottomLeft
  • fadeInBottomRight

🌫️ Fading Exits

  • fadeOut
  • fadeOutDown
  • fadeOutDownBig
  • fadeOutLeft
  • fadeOutLeftBig
  • fadeOutRight
  • fadeOutRightBig
  • fadeOutUp
  • fadeOutUpBig
  • fadeOutTopLeft
  • fadeOutTopRight
  • fadeOutBottomRight
  • fadeOutBottomLeft

πŸ”„ Flippers

  • flip
  • flipInX
  • flipInY
  • flipOutX
  • flipOutY

⚑ Lightspeed

  • lightSpeedInRight
  • lightSpeedInLeft
  • lightSpeedOutRight
  • lightSpeedOutLeft

πŸ”„ Rotating Entrances

  • rotateIn
  • rotateInDownLeft
  • rotateInDownRight
  • rotateInUpLeft
  • rotateInUpRight

πŸ”„ Rotating Exits

  • rotateOut
  • rotateOutDownLeft
  • rotateOutDownRight
  • rotateOutUpLeft
  • rotateOutUpRight

πŸ“ Sliding Entrances

  • slideInDown
  • slideInLeft
  • slideInRight
  • slideInUp

πŸ“ Sliding Exits

  • slideOutDown
  • slideOutLeft
  • slideOutRight
  • slideOutUp

πŸ“ Sliding Entrances

  • slideInDown
  • slideInLeft
  • slideInRight
  • slideInUp

πŸ“ Sliding Exits

  • slideOutDown
  • slideOutLeft
  • slideOutRight
  • slideOutUp

πŸ” Zooming Entrances

  • zoomIn
  • zoomInDown
  • zoomInLeft
  • zoomInRight
  • zoomInUp

πŸ” Zooming Exits

  • zoomOut
  • zoomOutDown
  • zoomOutLeft
  • zoomOutRight
  • zoomOutUp

⭐ Special Animations

  • hinge
  • jackInTheBox
  • rollIn
  • rollOut

🎯 Common Shortcuts

  • fade
  • slide-up
  • slide-down
  • slide-left
  • slide-right
  • zoom
  • elastic
  • attention
  • jack

πŸ“‹ Examples

Performance

Use data-scroll-container for multiple elements

Accessibility

Framework automatically supports prefers-reduced-motion

Debug

Use debug: true during development

Stagger

Use stagger effects for multiple elements to add visual richness

Observed Elements: 0
Animated Elements: 0
Performance: Good