bertux77/laravel-inview-animations
Laravel package for in-view animations using IntersectionObserver. Add a Blade component to auto-load CSS/JS, then animate elements via data-anim on .reveal with delays/duration. Includes many reveal effects plus animated counters and progress/ring charts for dashboards and landing pages.
Installation
composer require bertux77/laravel-inview-animations
Publish the config (if needed):
php artisan vendor:publish --provider="Bertux77\LaravelInviewAnimations\LaravelInviewAnimationsServiceProvider"
Basic Blade Usage
Add the package's JS/CSS to your layout (usually app.blade.php):
@inviewAnimations
Use the inview directive on any element:
<div inview="reveal">
This will fade in when scrolled into view.
</div>
First Use Case Animate a hero section on a landing page:
<section inview="reveal" data-inview-options='{"delay": 100, "duration": 1000}'>
<h1 class="text-4xl">Welcome to our site</h1>
</section>
Reveal Animations
<!-- Basic reveal -->
<div inview="reveal">...</div>
<!-- With custom options -->
<div inview="reveal" data-inview-options='{"direction": "bottom", "easing": "ease-in-out"}'>...</div>
Counter Animations
<div inview="counter" data-inview-options='{"from": 0, "to": 1000, "suffix": "+", "duration": 2000}'>
{{ $counter }}
</div>
Skill Bars
<div inview="skill-bar" data-inview-options='{"percentage": 90, "color": "#4CAF50", "height": "20px"}'>
<div class="skill-bar-fill"></div>
</div>
<div inview="counter" data-inview-options='{"from": 0, "to": {{ $dynamicValue }}, "duration": 2000}'>...</div>
@media queries or Laravel logic:
@if(!request()->isMobile())
<div inview="reveal">...</div>
@endif
app/Providers/AppServiceProvider.php:
use Bertux77\LaravelInviewAnimations\Facades\InviewAnimations;
InviewAnimations::extend('custom', function ($element, $options) {
// Custom logic
});
Performance
data-inview-options to throttle animations:
<div inview="reveal" data-inview-options='{"throttle": 500}'>...</div>
Mobile Devices
IntersectionObserver reliably. Test thoroughly.<div inview="reveal" class="fade-in">...</div>
Caching Issues
php artisan view:clear
F12) to see if the package JS loads and if errors appear.@inviewAnimations is included in the Blade template.data-inview attributes are present on target elements.config/inview-animations.php:
'default_options' => [
'rootMargin' => '0px',
'threshold' => 0.1,
],
threshold to control when animations trigger (e.g., 0.5 for halfway into view).Custom Animations Register new animations in the service provider:
InviewAnimations::extend('bounce', function ($element, $options) {
$element->classList.add('bounce-animation');
});
Then use in Blade:
<div inview="bounce">...</div>
Event Listeners Listen for animation events via JavaScript:
document.addEventListener('inview:start', (e) => {
console.log('Animation started:', e.detail.element);
});
Server-Side Logic Use Laravel to dynamically generate animation options:
$options = [
'delay' => auth()->check() ? 300 : 0,
'duration' => config('app.environment') === 'production' ? 1500 : 500,
];
<div inview="reveal" data-inview-options='@json($options)'>...</div>
How can I help you explore Laravel packages today?