A powerful, lightweight animation library for creating high-performance web animations with advanced features and minimal effort.
- High Performance: Hardware-accelerated animations with GPU optimization
- Responsive: Seamless performance across all devices and screen sizes
- Zero Dependencies: Standalone functionality with no external requirements
- Lightweight: Only 12.06KB compressed (CSS: 7.47KB, JS: 4.59KB), ~4KB minified
- Multiple Effects: 10+ built-in animation effects
- Sequence Animations: Create choreographed animation sequences
- Synchronized Animations: Coordinate multiple animations together
- Custom Timing: Control animation duration and easing per element
- Virtual Scrolling: Efficient handling of large lists
- Lazy Loading: Optimized image and resource loading
- Batch Processing: Smart animation queuing system
- Performance Mode: Automatic optimization for low-end devices
- Memory Management: Efficient resource cleanup and optimization
- Event System: Complete animation lifecycle events
- RTL Support: Full Right-to-Left language support
- Flexible API: Both attribute-based and programmatic control
- Group Animations: Coordinated animation patterns for groups
<!-- CSS -->
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/animflow@latest/dist/css/AnimFlow.css">
<!-- JavaScript -->
<script src="https://cdn.jsdelivr.net/npm/animflow@latest/dist/js/AnimFlow.js"></script>
npm install animflow
<!-- Add animation to any element using data-anim attribute -->
<div data-anim="fade-in">Fade in element</div>
<script>
// Initialize AnimFlow with options
AnimFlow.init({
repeat: 'always', // 'always', 'once', or 'none'
enableLazyLoading: true,
performance: {
useGPU: true,
batchSize: 10
}
});
</script>
// Initialize with advanced options
const anim = AnimFlow.init({
threshold: 0.1,
rootMargin: '0px',
repeat: 'always',
enableLazyLoading: true,
enableVirtualScroll: true,
virtualScrollItemHeight: 50,
rtl: true,
performance: {
useGPU: true,
batchSize: 10,
debounceTime: 10
}
});
// Event handling
anim.on('animationStart', data => console.log('Animation started', data));
anim.on('animationEnd', data => console.log('Animation completed', data));
// Initialize virtual scrolling for large lists
AnimFlow.VirtualScroller.init(container, 50);
<div class="sequence-group">
<div data-anim="slide-in" data-anim-sequence="0">First</div>
<div data-anim="slide-in" data-anim-sequence="1">Second</div>
<div data-anim="slide-in" data-anim-sequence="2">Third</div>
</div>
<img data-src="image.jpg" data-anim="fade-in" alt="Lazy loaded image">
- Chrome (latest)
- Firefox (latest)
- Safari (latest)
- Edge (latest)
- IE11 (basic support)
- Automatically detects low-performance devices
- Optimizes animations for better performance
- Uses hardware acceleration when available
- Implements efficient resource management
- Provides virtual scrolling for large lists
Contributions are welcome! Please read our contributing guidelines before submitting pull requests.
MIT License - see the LICENSE file for details.
<script src="https://cdn.jsdelivr.net/npm/animflow@latest/dist/js/AnimFlow.js"></script>
#### unpkg
```html
<!-- CSS -->
<link rel="stylesheet" href="https://unpkg.com/animflow@latest/dist/css/AnimFlow.css">
<!-- JavaScript -->
<script src="https://unpkg.com/animflow@latest/dist/js/AnimFlow.js"></script>
npm install animflow
Then use in your project:
// Require CSS
require('animflow/dist/css/AnimFlow.main.css');
// Require JavaScript
const AnimFlow = require('animflow/dist/js/AnimFlow.main.js');
- Add the
data-anim
attribute to elements you want to animate:
<div data-anim="fade-in">
This will fade in when scrolled into view
</div>
- Initialize AnimFlow:
const animFlow = new AnimFlow({
duration: 1000,
easing: 'cubic-bezier(0.16, 1, 0.3, 1)',
once: false,
mirror: true,
stagger: 200,
performanceMode: 'auto',
batchSize: 10
});
fade-in
: Fade in with slight upward movementslide-in
: Slide in from bottomslide-left
: Slide in from leftslide-right
: Slide in from rightscale-in
: Scale up smoothlyscale-bounce
: Scale up with bounce effectparallax
: Smooth parallax scrolling effectfade-up
: Fade in with upward movementrotate-in
: Rotate and scale in
<svg data-anim="draw-path">
<path d="M10 10 L90 90" />
</svg>
<div data-anim-group="cards" data-anim-mode="sequence">
<div data-anim="fade-in">Card 1</div>
<div data-anim="fade-in">Card 2</div>
<div data-anim="fade-in">Card 3</div>
</div>
<div
data-anim="slide-in"
data-anim-delay="200"
data-anim-duration="1500"
data-anim-easing="cubic-bezier(0.34, 1.56, 0.64, 1)">
Custom timing animation
</div>
{
offset: 100, // Parallax scroll offset
delay: 0, // Base delay for animations
duration: 1000, // Animation duration in ms
easing: 'cubic-bezier(0.16, 1, 0.3, 1)', // Animation timing function
once: false, // Run animation only once
mirror: true, // Reset animation when scrolling up
stagger: 200, // Delay between group animations
threshold: [0, 0.2], // Intersection observer thresholds
drawDuration: 1500, // SVG path drawing duration
performanceMode: 'auto', // Performance optimization mode
batchSize: 10, // Batch size for performance mode
groupModes: {
sequence: true, // Enable sequence mode for groups
random: true // Enable random mode for groups
}
}
AnimFlow includes an intelligent performance optimization system that automatically adjusts animation processing based on the number of animated elements and device capabilities:
auto
: Automatically switches to batch processing when neededforce
: Always uses batch processing for animationsoff
: Processes all animations immediately
When performance mode is active, AnimFlow processes animations in batches to maintain smooth performance:
const animFlow = new AnimFlow({
performanceMode: 'auto',
batchSize: 10
});
Different animation patterns for grouped elements:
sequence
: Animate elements one after anotherrandom
: Animate elements in random ordersync
: Animate all elements simultaneously
<div data-anim-group="cards" data-anim-mode="sequence">
</div>
- Chrome (latest)
- Firefox (latest)
- Safari (latest)
- Edge (latest)
- iOS Safari
- Android Chrome
- Use
transform
andopacity
for smooth animations - Enable hardware acceleration for better performance
- Use appropriate thresholds for intersection observer
- Optimize SVG paths for smoother animations
- Use performance mode for large number of animations
- Choose appropriate batch sizes based on device capabilities
- Use group modes effectively for complex animations
MIT License - Feel free to use in personal and commercial projects.
- Fork the repository
- Create your feature branch
- Commit your changes
- Push to the branch
- Create a new Pull Request
For issues and feature requests, please use the GitHub issues page.