Que fait lottie ?
Modèles d'adaptateur Lottie et dotLottie pour HyperFrames. À utiliser pour intégrer des animations JSON lottie-web, des fichiers .lottie, des lecteurs @lottiefiles/dotlottie-web, enregistrer des instances sur window.__hfLottie ou rendre les exportations After Effects déterministes dans HyperFrames.
Installation
npm install heygen-com/lottie
Utilisation
Adaptateur Lottie (JSON)
import { LottieAdapter } from 'heygen-com/lottie';
const adapter = new LottieAdapter({
container: document.getElementById('animation-container'),
animationData: animationData // Objet JSON d'animation lottie-web
});
adapter.mount();
Adaptateur dotLottie (.lottie)
import { DotLottieAdapter } from 'heygen-com/lottie';
const adapter = new DotLottieAdapter({
container: document.getElementById('animation-container'),
src: '/chemin/vers/animation.lottie'
});
adapter.mount();
Enregistrement d'instance
Pour garantir la compatibilité avec HyperFrames, enregistrez votre instance Lottie sur window.__hfLottie :
import { registerLottieInstance } from 'heygen-com/lottie';
const instance = new LottieAdapter({ ... });
registerLottieInstance(instance);
API
| Méthode | Description |
|---|---|
mount() | Monte l'adaptateur et lance l'animation |
unmount() | Démantele l'adaptateur et nettoie les ressources |
play() | Joue l'animation |
pause() | Met en pause l'animation |
setSpeed(speed) | Définit la vitesse de lecture (ex : 2 pour 2x) |
Licence
MIT