changed laoding of background
This commit is contained in:
parent
fb841cb17c
commit
f83a6add48
@ -8,16 +8,25 @@ export const ParticlesBackground = () => {
|
|||||||
const { theme } = useTheme();
|
const { theme } = useTheme();
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
// Retarder l'initialisation des particules pour ne pas bloquer le premier rendu
|
// Utiliser requestIdleCallback pour initialiser dès que le navigateur est idle
|
||||||
const timer = setTimeout(() => {
|
// Cela permet de démarrer plus tôt sans bloquer le thread principal
|
||||||
|
const idleCallback = window.requestIdleCallback || ((cb) => setTimeout(cb, 1));
|
||||||
|
|
||||||
|
const idleId = idleCallback(() => {
|
||||||
initParticlesEngine(async (engine) => {
|
initParticlesEngine(async (engine) => {
|
||||||
await loadSlim(engine);
|
await loadSlim(engine);
|
||||||
}).then(() => {
|
}).then(() => {
|
||||||
setInit(true);
|
setInit(true);
|
||||||
});
|
});
|
||||||
}, 1000); // Attendre 1 seconde après le chargement initial
|
}, { timeout: 1000 }); // Fallback timeout de 1s si le navigateur ne devient jamais idle
|
||||||
|
|
||||||
return () => clearTimeout(timer);
|
return () => {
|
||||||
|
if (window.cancelIdleCallback) {
|
||||||
|
window.cancelIdleCallback(idleId);
|
||||||
|
} else {
|
||||||
|
clearTimeout(idleId);
|
||||||
|
}
|
||||||
|
};
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
const particlesLoaded = async (container) => {
|
const particlesLoaded = async (container) => {
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user