π 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
- 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
- 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