.png)
This provides smooth scrolling across the entire template. To turn off just comment out this code.
<link rel="stylesheet" href="https://unpkg.com/lenis@1.3.20/dist/lenis.css" />
<script src="https://unpkg.com/lenis@1.3.20/dist/lenis.min.js"></script>
<script>
gsap.registerPlugin(ScrollTrigger);
const lenis = new Lenis({
duration: 1.5,
easing: (t) => 1 - Math.pow(1 - t, 3),
smooth: true,
smoothTouch: false, // ✅ important
});
// sync
lenis.on('scroll', ScrollTrigger.update);
// raf loop
function raf(time) {
lenis.raf(time);
requestAnimationFrame(raf);
}
requestAnimationFrame(raf);
// ✅ correct scroller
ScrollTrigger.scrollerProxy(document.documentElement, {
scrollTop(value) {
return arguments.length ? lenis.scrollTo(value, { immediate: true }) : lenis.scroll;
},
getBoundingClientRect() {
return {
top: 0,
left: 0,
width: window.innerWidth,
height: window.innerHeight,
};
},
});
// ✅ important
ScrollTrigger.defaults({
scroller: document.documentElement,
});
// refresh fix
ScrollTrigger.addEventListener('refresh', () => lenis.resize());
ScrollTrigger.refresh();
</script>This powers the animated counter effect across the template. To disable it, simply comment out or remove the script.
<!-- GSAP Counter Animation -->
<script src="https://cdnjs.cloudflare.com/ajax/libs/gsap/3.12.5/ScrollTrigger.min.js"></script>
<script>
window.addEventListener('load', function () {
gsap.registerPlugin(ScrollTrigger);
const counters = document.querySelectorAll('[data-target]');
counters.forEach(function (el, index) {
const target = parseFloat(el.getAttribute('data-target'));
const isDecimal = target % 1 !== 0;
gsap.set(el, { opacity: 0, y: 0 });
ScrollTrigger.create({
trigger : el,
start : 'top 85%',
once : true,
onEnter : function () {
const entryDelay = index * 0.3;
// Fade in
gsap.to(el, { opacity: 1, duration: 0.3, delay: entryDelay });
// 🎯 Smooth duration
const baseSpeed = 40;
const duration = Math.min(3, Math.max(0.8, target / baseSpeed));
const obj = { val: 0 };
gsap.to(obj, {
val : target,
duration : duration,
delay : entryDelay,
ease : 'power2.out',
onUpdate : function () {
el.innerText = isDecimal
? obj.val.toFixed(1)
: Math.floor(obj.val);
}
});
}
});
});
});
</script>Join thousands of happy customers who are already enjoying clean energy and significant savings. Get your free consultation today.