mirror of
https://github.com/chillpadclub/bedolaga-cabinet.git
synced 2026-07-30 02:23:47 +00:00
fix: replace framer-motion with CSS keyframes in boxes background
The boxes background was creating 225 motion.div elements, each running independent opacity animations via framer-motion JS on the main thread. This blocked hover transitions on cards, causing visible flickering. CSS @keyframes run on the compositor thread and have zero main-thread cost, eliminating the interference with user interactions.
This commit is contained in:
@@ -1,5 +1,4 @@
|
|||||||
import React, { useMemo } from 'react';
|
import React, { useMemo } from 'react';
|
||||||
import { motion } from 'framer-motion';
|
|
||||||
import { sanitizeColor, clampNumber } from './types';
|
import { sanitizeColor, clampNumber } from './types';
|
||||||
|
|
||||||
interface Props {
|
interface Props {
|
||||||
@@ -37,6 +36,13 @@ export default React.memo(function BackgroundBoxes({ settings }: Props) {
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="absolute inset-0 overflow-hidden">
|
<div className="absolute inset-0 overflow-hidden">
|
||||||
|
{/* CSS keyframes for box fade — runs on compositor thread, zero main-thread cost */}
|
||||||
|
<style>{`
|
||||||
|
@keyframes boxFade {
|
||||||
|
0%, 100% { opacity: 0; }
|
||||||
|
50% { opacity: 0.15; }
|
||||||
|
}
|
||||||
|
`}</style>
|
||||||
<div
|
<div
|
||||||
style={{
|
style={{
|
||||||
position: 'absolute',
|
position: 'absolute',
|
||||||
@@ -49,21 +55,18 @@ export default React.memo(function BackgroundBoxes({ settings }: Props) {
|
|||||||
gridTemplateColumns: `repeat(${cols}, 1fr)`,
|
gridTemplateColumns: `repeat(${cols}, 1fr)`,
|
||||||
transform: 'skewX(-48deg) skewY(14deg) scale(0.675) translateZ(0)',
|
transform: 'skewX(-48deg) skewY(14deg) scale(0.675) translateZ(0)',
|
||||||
transformOrigin: 'center center',
|
transformOrigin: 'center center',
|
||||||
|
contain: 'strict',
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
{cells.map((cell, i) => (
|
{cells.map((cell, i) => (
|
||||||
<motion.div
|
<div
|
||||||
key={i}
|
key={i}
|
||||||
className="border border-slate-700/50"
|
className="border border-slate-700/50"
|
||||||
initial={{ opacity: 0 }}
|
style={{
|
||||||
animate={{ opacity: [0, 0.15, 0] }}
|
backgroundColor: cell.color,
|
||||||
transition={{
|
animation: `boxFade ${cell.duration}s ${cell.delay}s ease-in-out infinite`,
|
||||||
duration: cell.duration,
|
opacity: 0,
|
||||||
delay: cell.delay,
|
|
||||||
repeat: Infinity,
|
|
||||||
ease: 'easeInOut',
|
|
||||||
}}
|
}}
|
||||||
style={{ backgroundColor: cell.color }}
|
|
||||||
/>
|
/>
|
||||||
))}
|
))}
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
Reference in New Issue
Block a user