Zum Hauptinhalt springen Seitenleiste
Auf dieser Seite
Zum Inhaltsverzeichnis springen

Animation

<pc-animation> 0.4.0 experimental

Animiere Elemente deklarativ mit fast 100 integrierten Presets oder erstelle deine eigenen Animationen mit benutzerdefinierten Keyframes. Diese Animationen basieren auf der Web Animations API.

Um ein Element zu animieren, umschließe es mit einem <pc-animation>‐Element und lege einen Animationsnamen fest. Diese Animation startet erst, wenn du das play‐Attribut hinzufügst. In der Eigenschaften‐Tabelle findest du eine Liste aller Optionen.

<div class="animation-overview">
    <pc-animation name="bounce" duration="2000" play>
        <div class="box"></div>
    </pc-animation>
    <pc-animation name="jello" duration="2000" play>
        <div class="box"></div>
    </pc-animation>
    <pc-animation name="heartBeat" duration="2000" play>
        <div class="box"></div>
    </pc-animation>
    <pc-animation name="flip" duration="2000" play>
        <div class="box"></div>
    </pc-animation>
</div>

<style>
    .animation-overview .box {
        display: inline-block;
        inline-size: 100px;
        block-size: 100px;
        margin: 1.5rem;
        background-color: var(--pc-color-primary-fill-loud);
        border-radius: var(--pc-border-radius-l);
    }
</style>
Code Edit

Diese Animation wird nur auf das erste Kindelement innerhalb von <pc-animation> angewendet.

Demos

Animationen und Easings

Diese Demo zeigt alle integrierten Animationen und Easings. Die Animationen basieren auf der beliebten Animate.css‐Bibliothek.

Edit

Intersection Observer

Nutze einen Intersection Observer, um die Animation zu steuern, sobald ein Element in den Viewport eintritt oder ihn verlässt. Scrolle zum Beispiel die Box unten in den Bildschirm hinein und wieder heraus. Die Animation stoppt, wenn die Box den Viewport verlässt und startet bei jedem Eintritt neu.

Edit

Benutzerdefinierte Keyframes

Füge deine eigene Keyframes hinzu, damit du benutzerdefinierte Animationen erstellen kannst.

Edit

Animationen programmatisch starten

Animationen werden erst abgespielt, wenn du das play‐Attribut hinzufügst. Du kannst es anfangs weglassen und erst programmatisch hinzufügen, z. B. nach einer Benutzerinteraktion. In dieser Demo animiert der Button bei jedem Klick genau einmal.

Edit

Eigenschaften

NameBeschreibungReflektiertStandard
nameThe name of the built‐in animation to use. For custom animations, use the keyframes prop.
Typ: string
"none"
playPlays the animation. When omitted, the animation will be paused. This attribute will be automatically removed when the animation finishes or gets cancelled.
Typ: boolean
false
delayThe number of milliseconds to delay the start of the animation.
Typ: number
0
directionDetermines the direction of playback as well as the behaviour when reaching the end of an iteration. Learn more about the CSS animation-direction property.
Typ: PlaybackDirection
"normal"
durationThe number of milliseconds each iteration of the animation takes to complete.
Typ: number
1000
easingThe easing function to use for the animation. This can be an easing function name like easeInSine or a custom easing function like cubic-bezier(0.12, 0, 0.39, 0).
Typ: string
"ease-in-out"
endDelay
end-delay
The number of milliseconds to delay after the active period of an animation sequence.
Typ: number
0
fillSets how the animation applies styles to its target before and after its execution.
Typ: FillMode
"auto"
iterationsThe number of iterations to run before the animation completes. Infinity
iterationStart
iteration-start
The offset at which to start the animation, usually between 0 (start) and 1 (end).
Typ: number
0
keyframesThe keyframes to use for the animation. If this is set, the name attribute and property will be ignored.
Typ: Keyframe[] | undefined
playbackRate
playback-rate
Sets the animation’s playback rate. The default is 1, which plays the animation at a normal speed. Setting this to 2, for example, will double the animation’s speed. A negative value can be used to reverse the animation. This value can be changed without causing the animation to restart.
Typ: number
1
currentTimeGets and sets the current animation time.
Typ: CSSNumberish
updateComplete Ein schreibgeschütztes Promise, das erfüllt ist, sobald die Komponente fertig aktualisiert wurde.

Erfahre mehr über Attribute und Eigenschaften.

Slots

NameBeschreibung
(Standard)The element to animate. Avoid slotting in more than one element, as subsequent ones will be ignored. To animate multiple elements, either wrap them in a single container or use multiple <pc-animation> elements.

Erfahre mehr über die Benutzung von Slots.

Methoden

NameBeschreibungArgumente
cancel()Clears all keyframes caused by this animation and aborts its playback.
finish()Sets the playback time to the end of the animation corresponding to the current playback direction.

Erfahre mehr über Methoden.

Events

NameBeschreibungEvent‐Detail
pc-cancelEmitted when the animation is cancelled.
pc-finishEmitted when the animation finishes.
pc‐startEmitted when the animation starts or restarts.

Erfahre mehr über Events.

Importieren

Wenn du den Autoloader oder den Standard‐Loader nutzt, kannst du diesen Abschnitt überspringen. Falls du „Cherry Picking“ betreibst, kannst du die folgenden Snippets verwenden, um diese Komponente zu importieren.

CDN (Skript‐Tag)CDN (Import)npm (Import)

Um diese Komponente manuell vom CDN zu importieren, kannst du dieses Code‐Snippet kopieren und es in dein HTML einfügen.

<script type="module" src="https://cdn.jsdelivr.net/npm/placer-toolkit@1.0.0-alpha.3/cdn/components/animation/animation.js"></script>

Um diese Komponente manuell vom CDN zu importieren, kannst du dieses Code‐Snippet kopieren und es in deine JavaScript‐Datei einfügen.

import "https://cdn.jsdelivr.net/npm/placer-toolkit@1.0.0-alpha.3/cdn/components/animation/animation.js";

Um diese Komponente manuell von npm zu importieren, kannst du dieses Code‐Snippet kopieren und es in deine JavaScript‐Datei einfügen.

import "placer-toolkit/dist/components/animation/animation.js";

Wir würden uns freuen, von dir zu hören. Kontaktiere uns bitte bei Fragen oder Anliegen, die du hast.

Du kannst uns per E‐Mail unter placer.coc.reports+contact@gmail.com erreichen.

Wir freuen uns darauf, von dir zu hören!

Alles klar!
Gefährliche Lande

Ui! Du bist in die gefährlichen Lande von Placer Toolkit geraten. Version 0 ist veraltet und entspricht nicht den EU‐Datenschutzstandards, einschließlich DSGVO.

Willst du die neuesten Kräfte, Sicherheit und Compliance? Bleib bei der aktuellen Version von Placer Toolkit!

Ups! Aufladen!

Unsere Website ist zu 100 % frei von Cookies! Wir legen großen Wert auf deine Privatsphäre und speichern daher keinerlei Cookies oder persönliche Informationen über dich.

Dein Browserverlauf bleibt sauber und deine Daten sind geschützt, ganz im Einklang mit modernen Datenschutzstandards wie der DSGVO. Genieße deinen Besuch ganz ohne digitale Cookies! 🍪🚫

Weitere Informationen findest du in unserer Datenschutzerklärung.

Alles klar!