Was macht Lottie-Animation – Programmatische JSON-basierte Animationen?
Erstelle animierte Logos, Icons und Mikrointeraktionen als leichtgewichtige Lottie-JSON-Dateien. Kein After Effects nötig – Animationen werden vollständig im Code erstellt.
Übersicht
- Format: Lottie JSON (offener Standard)
- Player-Repository: github.com/LottieFiles/lottie-player
- Editor-Repository: github.com/marciogranzotto/lottie-tools (Open-Source-Webeditor)
- Lizenz: MIT
- Installation:
npm install lottie-webodernpm install @lottiefiles/lottie-player
Was ist Lottie?
Lottie ist ein JSON-basiertes Animationsformat. Animationen werden als keyframed Eigenschaften in einer strukturierten JSON-Datei beschrieben. Sie rendern in jeder Auflösung (vektorbasiert), sind extrem klein in der Dateigröße und laufen nativ auf Web, iOS, Android und React Native.
Lottie-JSON-Struktur
{
"v": "5.7.1", // Lottie-Version
"fr": 30, // Bildrate
"ip": 0, // Startframe
"op": 60, // Endframe – 2 Sekunden bei 30fps
"w": 400, // Breite
"h": 400, // Höhe
"assets": [], // Externe Assets (Bilder, Precomps)
"layers": [ // Animationsebenen (unten nach oben)
{
"ty": 4, // Formebene
"nm": "Circle", // Ebenenname
"ip": 0,
"op": 60,
"st": 0, // Startzeit
"ks": { // Transform-Eigenschaften
"o": { "a": 0, "k": 100 }, // Deckkraft (statisch)
"r": { "a": 0, "k": 0 }, // Rotation
"p": { // Position (animiert)
"a": 1, // a=1 bedeutet animiert
"k": [
{ "t": 0, "s": [200, 300], "e": [200, 100], "i": {"x": 0.5, "y": 1}, "o": {"x": 0.5, "y": 0} },
{ "t": 30, "s": [200, 100] }
]
},
"s": { "a": 0, "k": [100, 100] } // Skalierung
},
"shapes": [...] // Formdefinitionen
}
]
}
Ebenentypen
| ty | Typ | Beschreibung |
|---|---|---|
| 0 | Precomp | Verschachtelte Komposition |
| 1 | Solid | Einfarbige Ebene |
| 2 | Image | Bildebene |
| 3 | Null | Leerer Transform-Elternteil |
| 4 | Shape | Vektorformen (am häufigsten) |
| 5 | Text | Textebene |
Formtypen
| ty | Form |
|---|---|
| "rc" | Rechteck |
| "el" | Ellipse |
| "sr" | Stern/Polygon |
| "sh" | Pfad (Bezier) |
| "fl" | Füllung |
| "st" | Kontur |
| "gf" | Verlaufsfüllung |
| "gs" | Verlaufskontur |
| "tr" | Transform |
| "gr" | Gruppe |
Animationen im Code erstellen
Einfacher Einblendkreis
{
"v": "5.7.1",
"fr": 30,
"ip": 0,
"op": 30,
"w": 200,
"h": 200,
"layers": [{
"ty": 4,
"nm": "circle",
"ip": 0,
"op": 30,
"st": 0,
"ks": {
"o": {
"a": 1,
"k": [
{"t": 0, "s": [0], "e": [100], "i": {"x": [0.4], "y": [1]}, "o": {"x": [0.6], "y": [0]}},
{"t": 20, "s": [100]}
]
},
"r": {"a": 0, "k": 0},
"p": {"a": 0, "k": [100, 100]},
"s": {
"a": 1,
"k": [
{"t": 0, "s": [0, 0], "e": [100, 100], "i": {"x": [0.2, 0.2], "y": [1, 1]}, "o": {"x": [0.8, 0.8], "y": [0, 0]}},
{"t": 25, "s": [100, 100]}
]
}
},
"shapes": [
{
"ty": "gr",
"it": [
{"ty": "el", "p": {"a": 0, "k": [0, 0]}, "s": {"a": 0, "k": [80, 80]}},
{"ty": "fl", "c": {"a": 0, "k": [0.2, 0.5, 1, 1]}, "o": {"a": 0, "k": 100}},
{"ty": "tr", "p": {"a": 0, "k": [0, 0]}, "s": {"a": 0, "k": [100, 100]}}
]
}
]
}]
}
Keyframe-Easing
// Sanft ein- und ausblenden
"i": {"x": [0.42], "y": [1]},
"o": {"x": [0.58], "y": [0]}
// Ausblenden (verlangsamen)
"i": {"x": [0.0], "y": [1]},
"o": {"x": [0.6], "y": [0]}
// Einblenden (beschleunigen)
"i": {"x": [0.4], "y": [1]},
"o": {"x": [1.0], "y": [0]}
// Linear
"i": {"x": [1], "y": [1]},
"o": {"x": [0], "y": [0]}
Programmatische Erzeugung mit JavaScript
function createLottieAnimation({ width, height, fps, durationFrames, layers }) {
return {
v: "5.7.1",
fr: fps,
ip: 0,
op: durationFrames,
w: width,
h: height,
assets: [],
layers,
};
}
function createShapeLayer({ name, startFrame, endFrame, shapes, transform }) {
return {
ty: 4,
nm: name,
ip: startFrame,
op: endFrame,
st: startFrame,
ks: transform,
shapes,
};
}
// Erzeugen und speichern
const animation = createLottieAnimation({
width: 400, height: 400, fps: 30, durationFrames: 60,
layers: [/* ... */],
});
const fs = require("fs");
fs.writeFileSync("animation.json", JSON.stringify(animation, null, 2));
Lottie im Web abspielen
<!-- Über CDN -->
<script src="https://unpkg.com/@lottiefiles/lottie-player@latest/dist/lottie-player.js"></script>
<lottie-player src="animation.json" background="transparent" speed="1" loop autoplay></lottie-player>
// Über npm
import lottie from "lottie-web";
const anim = lottie.loadAnimation({
container: document.getElementById("lottie"),
renderer: "svg",
loop: true,
autoplay: true,
animationData: require("./animation.json"),
});
Lottie in Remotion verwenden
import { Lottie } from "@remotion/lottie";
import animationData from "./animation.json";
export const MyScene: React.FC = () => {
return <Lottie animationData={animationData} />;
};
Installation: npm install @remotion/lottie
Best Practices
- Halte es einfach – Weniger Ebenen = kleinere Datei, bessere Leistung
- Verwende Formebenen anstelle von Bildebenen, wenn möglich (Vektor = scharf in jeder Größe)
- Verwende Easing für Keyframes – Verwende niemals lineares Easing für organische Bewegungen
- 30fps ist Standard für Web-Lottie-Animationen
- Unter 2 Sekunden für Mikrointeraktionen, 3-5 Sekunden für Logos
- Teste mit lottie-player – Vorschau vor dem Einbetten
- Optimiere – Entferne ungenutzte Eigenschaften, minimiere die Genauigkeit von Zahlen
Agent-Skill-Quellen
- Wiggle (Logo-Animations-Skill): github.com/talknerdytome-labs/wiggle-claude-skill
- Lottie Tools (Editor): github.com/marciogranzotto/lottie-tools
- OmniLottie (KI-Generierung): github.com/OpenVGLab/OmniLottie