### List Example
Source: https://auto-animate.formkit.com/#installation/index
An example demonstrating adding and removing items from a list with auto-animate, including randomizing item positions.
```vue
{{ fruit }}
```
--------------------------------
### List Example with Bouncy Keyframes (Vue)
Source: https://auto-animate.formkit.com/#installation/index
Applies the custom 'bouncy' keyframes plugin to a list example, demonstrating the visual effect of the overshoot animation on list items.
```vue
{{ fruit }}
```
--------------------------------
### AutoAnimate Usage (React)
Source: https://auto-animate.formkit.com/#installation/index
Provides a React-specific example of using AutoAnimate with the `useAutoAnimate` hook for a more declarative approach to adding animations to components.
```jsx
import { useAutoAnimate } from '@formkit/auto-animate/react';
function MyListComponent() {
const [parent] = useAutoAnimate();
return (
Item 1
Item 2
Item 3
);
}
```
--------------------------------
### Angular Directive Setup
Source: https://auto-animate.formkit.com/#installation/index
Details how to globally register the `auto-animate` directive in Angular applications.
```angular
import { NgModule } from '@angular/core';
import { BrowserModule } from '@angular/platform-browser';
import { AppComponent } from './app.component';
import { AutoAnimateModule } from '@formkit/auto-animate/angular';
@NgModule({
declarations: [
AppComponent
],
imports: [
BrowserModule,
AutoAnimateModule
],
providers: [],
bootstrap: [AppComponent]
})
export class AppModule { }
```
--------------------------------
### Vue Directive Setup
Source: https://auto-animate.formkit.com/#installation/index
Explains how to globally register the `v-auto-animate` directive in Vue.js applications or use it directly within components.
```ts
import { createApp } from 'vue';
import App from './App.vue';
import { autoAnimatePlugin } from '@formkit/auto-animate/vue';
const app = createApp(App);
app.use(autoAnimatePlugin);
app.mount('#app');
```
```javascript
import { vAutoAnimate } from '@formkit/auto-animate';
// Usage within a component:
//
//
...
//
```
--------------------------------
### Vue Composable Usage
Source: https://auto-animate.formkit.com/#installation/index
Shows how to use the `useAutoAnimate` composable in Vue 3 with `script setup`. It provides a ref for the parent element and animation control functions.
```vue
Vue
```
--------------------------------
### Disabling Animations
Source: https://auto-animate.formkit.com/#installation/index
Provides examples of how to disable and re-enable animations using the `autoAnimate` function's controller or the `useAutoAnimate` hook's return value.
```jsx
import { useAutoAnimate } from '@formkit/auto-animate/react';
function App() {
const [parentRef, enableAnimations] = useAutoAnimate();
return (
);
}
```
```javascript
import autoAnimate from '@formkit/auto-animate';
const parent = document.getElementById('my-element');
const animationController = autoAnimate(parent);
// To disable:
animationController.disable();
// To enable:
animationController.enable();
```
--------------------------------
### Passing Options
Source: https://auto-animate.formkit.com/#installation/index
Demonstrates how to pass configuration options, such as duration, to the auto-animate functionality in different frameworks.
```vue
```
--------------------------------
### AutoAnimate Usage (TypeScript)
Source: https://auto-animate.formkit.com/#installation/index
Illustrates how to use AutoAnimate with TypeScript, including type definitions for the parent element and configuration options.
```typescript
import autoAnimate, { AutoAnimateOptions } from '@formkit/auto-animate';
const parent: HTMLElement = document.getElementById('my-list') as HTMLElement;
const options: AutoAnimateOptions = {
duration: 500,
easing: 'ease-out',
};
const animation = autoAnimate(parent, options);
```
--------------------------------
### AutoAnimate Configuration (JavaScript)
Source: https://auto-animate.formkit.com/#installation/index
Shows how to configure AutoAnimate with options such as animation duration, easing, and disabling for reduced motion. The configuration is passed as a second argument to the autoAnimate function.
```javascript
import autoAnimate from '@formkit/auto-animate';
const parent = document.getElementById('my-list');
const animation = autoAnimate(parent, {
duration: 300,
easing: 'ease-in-out',
// disable: true // Set to true to disable animations by default
});
// Example of disabling for reduced motion (though AutoAnimate does this automatically)
if (window.matchMedia('(prefers-reduced-motion: reduce)').matches) {
animation.disable();
}
```
--------------------------------
### Solid Primitive Usage
Source: https://auto-animate.formkit.com/#installation/index
Demonstrates how to use the `createAutoAnimate` function in Solid.js applications to animate elements.
```tsx
import { createAutoAnimate } from '@formkit/auto-animate/solid';
import { For } from 'solid-js';
function App() {
const [parentRef] = createAutoAnimate();
return (
Home
Settings
Logout
);
}
```
--------------------------------
### AutoAnimate Usage (JavaScript)
Source: https://auto-animate.formkit.com/#installation/index
Demonstrates the basic usage of the autoAnimate function by applying it to a parent element to animate its children's additions, removals, or movements.
```javascript
import autoAnimate from '@formkit/auto-animate';
const parent = document.getElementById('my-list');
const animation = autoAnimate(parent);
// To disable animations:
animation.disable();
// To re-enable animations:
animation.enable();
```
--------------------------------
### Preact Hook Usage
Source: https://auto-animate.formkit.com/#installation/index
Illustrates the usage of the `useAutoAnimate` hook in Preact applications, similar to the React implementation.
```jsx
import { useAutoAnimate } from '@formkit/auto-animate/preact';
function App() {
const [parentRef] = useAutoAnimate();
return (
Preact
🎁
📦
🚚
💪
🐽
🐻
);
}
```
--------------------------------
### Solid Directive Usage
Source: https://auto-animate.formkit.com/#installation/index
Shows how to apply the `autoAnimate` directive in Solid.js applications for element animations.
```tsx
import { autoAnimate } from '@formkit/auto-animate/solid';
function App() {
return (
Solid Logo
Solid
);
}
```
--------------------------------
### FAQ Accordion Animation (Vue)
Source: https://auto-animate.formkit.com/#installation/index
Shows how Auto Animate can be used to create smooth opening and closing animations for accordion items without relying on `max-height` transitions, preserving easing.
```vue
{{ item.answer }}
```
--------------------------------
### React Hook Usage
Source: https://auto-animate.formkit.com/#installation/index
Demonstrates how to use the `useAutoAnimate` hook in React applications. It returns a ref for the parent element and a function to control animations.
```jsx
import { useAutoAnimate } from '@formkit/auto-animate/react';
function App() {
const [parentRef] = useAutoAnimate();
return (
React Logo
React
React
0
1
2
);
}
```
--------------------------------
### Svelte Action Usage
Source: https://auto-animate.formkit.com/#installation/index
Explains how to use the `autoAnimate` function directly as a Svelte action for element animations.
```svelte
Svelte Logo
Svelte
Rock
Punk
```
--------------------------------
### Cards List Animation (Vue)
Source: https://auto-animate.formkit.com/#installation/index
Demonstrates animating a list of event cards. New events are added to the front, and all cards smoothly animate to their new positions. The parent container also resizes seamlessly.
```vue
{{ event.title }}
{{ event.date }}
{{ event.description }}
```
--------------------------------
### Angular Directive Usage
Source: https://auto-animate.formkit.com/#installation/index
Shows how to apply the `auto-animate` directive in Angular templates.
```angular
Angular
```
--------------------------------
### Custom Bouncy Keyframes Plugin (JavaScript)
Source: https://auto-animate.formkit.com/#installation/index
Provides a JavaScript plugin for Auto Animate that replaces default keyframes with custom ones to create a 'bouncy' animation effect for added/removed/remaining elements.
```javascript
import { autoAnimate } from '@formkit/auto-animate';
const bouncyKeyframes = (
element,
animationProperties
) => {
// Example custom keyframes for 'add' action
if (animationProperties.animationName === 'add') {
return [
{ transform: 'scale(1)', offset: 0 },
{ transform: 'scale(1.1)', offset: 0.5 },
{ transform: 'scale(0.9)', offset: 0.8 },
{ transform: 'scale(1)', offset: 1 },
];
}
// Return default keyframes or null if not handled
return null;
};
// Usage:
// const parent = document.getElementById('my-list');
// autoAnimate(parent, { keyframes: bouncyKeyframes });
```
--------------------------------
### FormKit Validation Message Animation (Vue)
Source: https://auto-animate.formkit.com/#installation/index
Demonstrates integrating Auto Animate with FormKit to animate the appearance and disappearance of validation messages associated with form inputs.
```vue
```
--------------------------------
### X/Y Axis Box Animation (Conceptual)
Source: https://auto-animate.formkit.com/#installation/index
Illustrates Auto Animate's capability to handle animations on both the X and Y axes simultaneously. This is useful for elements that move or wrap within their containers, ensuring smooth translations.
```javascript
// This is a conceptual representation of how auto-animate would be applied.
// The actual implementation would involve a container element with child elements.
// Assuming 'container' is a reference to the DOM element containing the boxes:
// import { autoAnimate } from '@formkit/auto-animate';
// autoAnimate(container);
// The HTML structure would likely involve a grid or flex layout:
/*
0
1
...
49
*/
// When elements are added, removed, or reordered, auto-animate handles the transitions.
```
=== COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.