Find easy to follow instructions
<!-- =========================================================
LENIS SMOOTH SCROLL
---------------------------------------------------------
Lenis handles smooth scrolling and is synchronized
with GSAP ScrollTrigger.
========================================================= -->
<script src="https://unpkg.com/lenis@1.3.4/dist/lenis.min.js"></script>
<link rel="stylesheet" href="https://unpkg.com/lenis@1.3.4/dist/lenis.css"/>
<script>
// Initialize Lenis smooth scrolling
const lenis = new Lenis({
smooth: true,
lerp: 0.1,
wheelMultiplier: 0.75,
infinite: false,
});
// Keep ScrollTrigger synchronized with Lenis
lenis.on("scroll", ScrollTrigger.update);
// Run Lenis through the GSAP ticker
gsap.ticker.add((time) => {
lenis.raf(time * 1000);
});
// Disable GSAP lag smoothing for consistent scroll synchronization
gsap.ticker.lagSmoothing(0);
</script>const lenis = new Lenis({
smooth: true, // Enables/disables smooth scrolling (true/false)
lerp: 0.1, // Scroll interpolation/smoothness (lower values = smoother/slower catch-up)
wheelMultiplier: 0.75, // Mouse wheel scroll speed multiplier
infinite: false, // Enables or disables infinite looping scroll
});// Disables GSAP's lag smoothing to ensure GSAP and Lenis tick on the exact same frame
gsap.ticker.lagSmoothing(0);// Remove or comment out these lines:
// lenis.on("scroll", ScrollTrigger.update);
// gsap.ticker.add((time) => { lenis.raf(time * 1000); });
// gsap.ticker.lagSmoothing(0);function raf(time) {
lenis.raf(time);
requestAnimationFrame(raf);
}
requestAnimationFrame(raf);<script>
window.Webflow = window.Webflow || [];
window.Webflow.push(function () {
if (!window.gsap) return;
const gsap = window.gsap;
const root = document.querySelector('.wrapper-circle-featured');
if (!root || root.dataset.portfolioHoverReady === 'true') return;
root.dataset.portfolioHoverReady = 'true';
const cards = Array.from(root.querySelectorAll('.block-image-feature'));
const heading = document.querySelector('.wrapper-title-featured');
const titles = Array.from(document.querySelectorAll('.title-project'));
if (!cards.length) return;
// Card variant -> title variant, matching the original portfolio hover setup.
const titleVariantByCard = {
v1: 'v2',
v2: 'v4',
v3: 'v1',
v4: 'v1',
v5: 'v3',
v6: 'v3',
};
const splitInstances = [];
titles.forEach((el) => {
if (window.SplitType) splitInstances.push(new SplitType(el, { types: 'words' }));
});
const wordsFor = (elements) => elements.flatMap((el) => Array.from(el.querySelectorAll('.word')));
const allWords = wordsFor(titles);
gsap.set(titles, { autoAlpha: 0 });
gsap.set(allWords, { yPercent: 30, autoAlpha: 0 });
const overlayFor = (card) => card.querySelector('.overlay-featured');
const allOverlays = cards.map(overlayFor).filter(Boolean);
let activeTimeline = null;
let activeCard = null;
function stopCurrentAnimation() {
if (activeTimeline) activeTimeline.kill();
activeTimeline = null;
gsap.killTweensOf([...allOverlays, heading, ...titles, ...allWords].filter(Boolean));
}
function activateCard(card) {
if (activeCard === card) return;
stopCurrentAnimation();
activeCard = card;
const activeOverlay = overlayFor(card);
const otherOverlays = allOverlays.filter((overlay) => overlay !== activeOverlay);
const cardVariant = Array.from(card.classList).find((name) => /^v[1-6]$/.test(name));
const titleVariant = titleVariantByCard[cardVariant];
const matchingTitles = titleVariant ? titles.filter((el) => el.classList.contains(titleVariant)) : [];
const otherTitles = titles.filter((el) => !matchingTitles.includes(el));
const matchingWords = wordsFor(matchingTitles);
activeTimeline = gsap.timeline({ defaults: { overwrite: true } });
// Explicitly clear the hovered card's overlay; dim only every other card.
if (activeOverlay) {
activeTimeline.to(
activeOverlay,
{
autoAlpha: 0,
duration: 0.25,
ease: 'power2.out',
},
0,
);
}
if (otherOverlays.length) {
activeTimeline.to(
otherOverlays,
{
autoAlpha: 0.8,
duration: 0.5,
ease: 'power2.out',
},
0,
);
}
if (heading) {
activeTimeline.to(
heading,
{
autoAlpha: 0,
duration: 0.35,
ease: 'power2.out',
},
0,
);
}
if (otherTitles.length) {
activeTimeline.set(otherTitles, { autoAlpha: 0 }, 0);
}
if (matchingTitles.length) {
activeTimeline.set(matchingTitles, { autoAlpha: 1 }, 0.12);
}
if (matchingWords.length) {
activeTimeline.fromTo(
matchingWords,
{ yPercent: 30, autoAlpha: 0 },
{
yPercent: 0,
autoAlpha: 1,
duration: 0.5,
stagger: 0.035,
ease: 'power3.out',
},
0.17,
);
}
}
function resetPortfolio() {
stopCurrentAnimation();
activeCard = null;
gsap.to(allOverlays, {
autoAlpha: 0,
duration: 0.35,
ease: 'power2.out',
overwrite: true,
});
if (heading) {
gsap.to(heading, {
autoAlpha: 1,
duration: 0.35,
ease: 'power2.out',
overwrite: true,
});
}
gsap.to(titles, { autoAlpha: 0, duration: 0.2, overwrite: true });
gsap.to(allWords, {
yPercent: 30,
autoAlpha: 0,
duration: 0.2,
stagger: 0.01,
ease: 'power2.in',
overwrite: true,
});
}
cards.forEach((card) => {
card.addEventListener('mouseenter', () => activateCard(card));
});
// Reset only after leaving the whole portfolio card area.
root.addEventListener('mouseleave', resetPortfolio);
window.addEventListener(
'pagehide',
() => {
if (activeTimeline) activeTimeline.kill();
splitInstances.forEach((split) => split.revert());
},
{ once: true },
);
});
</script>//This object determines which project title appears when a specific portfolio card is hovered.
const titleVariantByCard = {
v1: 'v2',
v2: 'v4',
v3: 'v1',
v4: 'v1',
v5: 'v3',
v6: 'v3',
};duration: 0.25, // Active card overlay fade-out
duration: 0.5, // Other cards overlay fade-in
duration: 0.35, // Main heading fade-out
duration: 0.5, // Word reveal duration
stagger: 0.035, // Delay between each word
duration: 0.35, // Overlay and heading reset
duration: 0.2, // Project title fade-outconst root = document.querySelector('.wrapper-circle-featured');
const cards = Array.from(
root.querySelectorAll('.block-image-feature')
);