Skip to content

Commit 2f9ecc7

Browse files
committed
perf(landing): remove liquid shader and throttle magic bento hover to fix lag
1 parent b458e1f commit 2f9ecc7

2 files changed

Lines changed: 13 additions & 8 deletions

File tree

‎apps/landing/src/components/MagicBento/MagicBento.jsx‎

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -357,16 +357,21 @@ const GlobalSpotlight = ({
357357
document.body.appendChild(spotlight);
358358
spotlightRef.current = spotlight;
359359

360+
let rAF = null;
361+
360362
const handleMouseMove = e => {
361-
if (!spotlightRef.current || !gridRef.current) return;
363+
if (rAF) cancelAnimationFrame(rAF);
364+
365+
rAF = requestAnimationFrame(() => {
366+
if (!spotlightRef.current || !gridRef.current) return;
362367

363-
const section = gridRef.current.closest('.bento-section');
364-
const rect = section?.getBoundingClientRect();
365-
const mouseInside =
366-
rect && e.clientX >= rect.left && e.clientX <= rect.right && e.clientY >= rect.top && e.clientY <= rect.bottom;
368+
const section = gridRef.current.closest('.bento-section');
369+
const rect = section?.getBoundingClientRect();
370+
const mouseInside =
371+
rect && e.clientX >= rect.left && e.clientX <= rect.right && e.clientY >= rect.top && e.clientY <= rect.bottom;
367372

368-
isInsideSection.current = mouseInside || false;
369-
const cards = gridRef.current.querySelectorAll('.magic-bento-card');
373+
isInsideSection.current = mouseInside || false;
374+
const cards = gridRef.current.querySelectorAll('.magic-bento-card');
370375

371376
if (!mouseInside) {
372377
gsap.to(spotlightRef.current, {
@@ -423,6 +428,7 @@ const GlobalSpotlight = ({
423428
duration: targetOpacity > 0 ? 0.2 : 0.5,
424429
ease: 'power2.out'
425430
});
431+
});
426432
};
427433

428434
const handleMouseLeave = () => {

‎apps/landing/src/pages/index.astro‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,6 @@ const FAQ_ITEMS = [
8282
<div class="hyperspeed-wrapper">
8383
<Hyperspeed client:load effectOptions={HYPERSPEED_OPTIONS} />
8484
</div>
85-
<LiquidBackground client:load />
8685
<div class="hero-glow"></div>
8786

8887
<div class="hero-split" style="position: relative; z-index: 1;">

0 commit comments

Comments
 (0)