Configs2026年7月23日·1 分钟阅读

AutoAnimate — Zero-Config Drop-In Animation Utility

A zero-configuration animation library that automatically adds smooth transitions when DOM elements are added, removed, or moved within a parent container.

Agent 就绪

Agent 可直接安装

这个资产可安装;Agent 先选择当前运行时、检查安装计划,再运行匹配命令。

Native · 98/100策略:允许
Agent 入口
任意 MCP/CLI Agent
类型
Skill
安装
Single
信任
信任等级:Established
入口
AutoAnimate Overview
直接安装命令
npx -y tokrepo@latest install d9544315-862d-11f1-9bc6-00163e2b0d79 --target codex

先 dry-run 确认安装计划,再运行此命令。

Introduction

AutoAnimate watches a parent element for changes to its children and applies smooth transitions automatically. When items are added, removed, or reordered, AutoAnimate handles the enter, leave, and move animations. It works with vanilla JavaScript, React, Vue, Svelte, and Angular with no configuration required.

What AutoAnimate Does

  • Animates new child elements entering a container with a fade-in and scale effect
  • Animates removed child elements with a fade-out transition
  • Smoothly repositions child elements when their order changes in the DOM
  • Provides framework-specific hooks: useAutoAnimate for React, v-auto-animate for Vue
  • Allows custom animation overrides via a plugin function

Architecture Overview

AutoAnimate uses MutationObserver to detect when children of the target element change. On each mutation, it snapshots the current positions of all children using getBoundingClientRect, then uses the Web Animations API (WAAPI) to interpolate from old to new positions. Enter and leave animations are handled with opacity and transform keyframes. The entire system runs in a single requestAnimationFrame cycle per mutation batch.

Self-Hosting & Configuration

  • Install via npm or import from a CDN
  • Call autoAnimate(parentElement) for instant zero-config animation
  • Pass a duration number as the second argument to control speed (default 250ms)
  • Use autoAnimate(el, customPlugin) to override the default animation behavior
  • For React, use the useAutoAnimate() hook to get a ref callback

Key Features

  • True zero-config: one function call animates adds, removes, and reorders
  • Framework adapters for React, Vue, Svelte, Angular, and SolidJS
  • Tiny bundle size (~2 KB gzipped) with no dependencies
  • Uses the native Web Animations API for smooth 60fps transitions
  • Custom plugin system for full control over keyframes and timing

Comparison with Similar Tools

  • Framer Motion (Motion) — powerful React animation library with layout animations; AutoAnimate is simpler and framework-agnostic
  • Vue Transition Group — Vue-specific with CSS class hooks; AutoAnimate requires no CSS
  • react-spring — spring-physics animations; AutoAnimate provides instant list transitions without physics configuration
  • FLIP technique — the underlying approach AutoAnimate uses; it automates what developers would otherwise code manually

FAQ

Q: Does AutoAnimate work with virtual lists? A: It works best with standard DOM lists. Virtualized lists that recycle DOM nodes may produce unexpected animation triggers.

Q: Can I disable animation temporarily? A: Yes. The autoAnimate() call returns an enable/disable controller. Call controller.disable() to pause and controller.enable() to resume.

Q: What browsers are supported? A: Any browser that supports MutationObserver and the Web Animations API, which includes all modern browsers.

Q: Can I customize the animation? A: Yes. Pass a plugin function as the second argument. It receives the element, action (add/remove/remain), and coordinates, and returns a KeyframeEffect.

Sources

讨论

登录后参与讨论。
还没有评论,来写第一条吧。

相关资产