A lightweight, CSS-only scroll reveal animation system using modern scroll-driven animations API
npm install @toms15/scroll-reveal-animationsA lightweight, CSS-only scroll reveal animation system using modern scroll-driven animations API. Perfect for WordPress, Sage, and any modern web project.
- ✨ Pure CSS animations (no JavaScript required for basic usage)
- 🎯 Highly customizable with CSS custom properties
- 🚀 Performance optimized with will-change
- ♿ Accessible (respects prefers-reduced-motion)
- 📦 Lightweight (~3KB minified)
- 🎨 Multiple preset variants
- 🔄 Stagger animations support
- 🌐 Modern browser support
``bash`
npm install @toms15/scroll-reveal-animations
`bash`
yarn add @toms15/scroll-reveal-animations
#### Import CSS
`javascript`
// In your main JS file
import '@toms15/scroll-reveal-animations/dist/scroll-reveal.css';
Or in your CSS/SCSS:
`css`
@import '@toms15/scroll-reveal-animations/dist/scroll-reveal.css';
#### HTML
`html`
This will fade in on scroll
`htmlContent
$3
`html
Custom animation
`$3
#### With JavaScript (Recommended)
`javascript
import ScrollReveal from '@toms15/scroll-reveal-animations';// Auto-initialize
new ScrollReveal();
``html
Item 1
Item 2
Item 3
`#### Without JavaScript
`html
Item 1
Item 2
Item 3
`$3
resources/scripts/app.js:
`javascript
import ScrollReveal from '@toms15/scroll-reveal-animations';
import '@toms15/scroll-reveal-animations/dist/scroll-reveal.css';domReady(() => {
new ScrollReveal({ debug: true });
});
`In your Blade template:
`html
@foreach($items as $item)
{{ $item->title }}
@endforeach
`Customization
$3
`css
.scroll-reveal {
--reveal-opacity-from: 0;
--reveal-opacity-to: 1;
--reveal-translate-y: 100px;
--reveal-translate-x: 0px;
--reveal-scale: 1;
--reveal-rotate: 0deg;
--reveal-blur: 0px;
--reveal-delay: 0ms;
--reveal-range-start: entry 10%;
--reveal-range-end: cover 30%;
--reveal-easing: cubic-bezier(0, 0.69, 0.57, 0.56);
}
`$3
`javascript
const scrollReveal = new ScrollReveal({
staggerGroupSelector: '[data-stagger-group]',
staggerItemSelector: '[data-stagger]',
autoInit: true,
debug: false
});// Refresh after dynamic content
scrollReveal.refresh();
// Check browser support
const support = scrollReveal.getSupport();
console.log(support);
// Manually set stagger index
scrollReveal.setStaggerIndex(element, 5);
`Browser Support
Requires browsers that support CSS Scroll-driven Animations:
- ✅ Chrome/Edge 115+
- ⚠️ Safari 17.5+ (partial support)
- ⚠️ Firefox: Behind flag (experimental)
Graceful Degradation: Unsupported browsers will display all elements without animation.
Troubleshooting
$3
1. Check browser support
2. Verify CSS is imported
3. Check if
prefers-reduced-motion is enabled
4. Inspect element styles in DevTools$3
1. Ensure JavaScript is imported and initialized
2. Check
data-stagger-group wrapper exists
3. Verify items have data-stagger attribute
4. Check console for errors with debug: true`Contributions are welcome! Please:
1. Fork the repository
2. Create a feature branch
3. Make your changes
4. Add tests if applicable
5. Submit a pull request
MIT © Toms15
- GitHub Repository
- NPM Package
- Report Issues
- MDN: Scroll-driven Animations