@asika32764/vue-animate

中文文档
3.0.2发布于 2023/10/21MITTypeScriptESM + CJS零依赖近 30 天下载 5547

Version License

原始使用文档
文档目录15 节
  1. Credit
  2. Table of Contents
  3. Installation
  4. Import
  5. Transitions
  6. Custom Transition Classes
  7. Custom Animation Properties
  8. Slide as Mobile
  9. Work with Alpine.js
  10. Attentions Seekers
  11. Options
  12. Contribution Guide
  13. Build Lib
  14. Build Docs
  15. Sync from animate.css

vue-animate

Version License

Cross-browser CSS3 animation library, a port of animate.css for use with Vue.js transitions. DEMO

Support for:

  • Vue 2.x
  • Vue 3.x
  • Alpine.js

Credit

Table of Contents

Installation

From NPM

npm i @asika32764/vue-animate --save

yarn add @asika32764/vue-animate

CDN

<link rel="stylesheet" href="https://www.unpkg.com/@asika32764/vue-animate/dist/vue-animate.min.css"/>

Import

Import animations for JS Bundler.

import '@asika32764/vue-animate/dist/vue-animate.css';

Import in CSS or SCSS file.

@import "@asika32764/vue-animate/dist/vue-animate.css";

/* If you want to override CSS variables, write it just after importing */
:root {
  --animate-duration: .3s;
  --animate-delay: 0;
}

Transitions

Use Vue.js transitions as you normally would, but for the transition name you will use one of Animate.css animations removing the animate__ and in/Out from the name.

For example, if you want to use animate__animated animate__fadeInLeft and animate__fadeInLeft on your element, You could write:

<TransitionGroup name="fadeLeft" tag="ul">
    <li v-for="item in items" :key="item.id">
        {{ item }}
    </li>
</TransitionGroup>

enter/leave is already written in the stylesheet, so just remove In/Out from the name and you're golden.

Custom Transition Classes

Animate.css's original classnames are supported on enter/leave transitions. So if you're going to use Custom Transition Classes, you can either add -enter/-leave to the classes:

<Transition
  name="custom-classes-transition"
  enter-active-class="bounceLeft-enter"
  leave-active-class="bounceRight-leave"
>
  <p v-if="show">hello</p>
</Transition>

Or use the regular In/Out syntax:

<Transition
  name="bounce"
  enter-active-class="bounceInLeft"
  leave-active-class="bounceOutRight"
>
  <p v-if="show">hello</p>
</Transition>

Custom Animation Properties

<Transition name="fade">
  <p v-if="show" 
    style="--animate-duration: 0.3s; --animate-delay: 150; --animate-direction: reverse;"
  >hello</p>
</Transition>

Slide as Mobile

The view element must set position as absolute.

<Transition
    enter-active-class="position-absolute slideInRight"
    leave-active-class="position-absolute slideOutLeft">
    <router-view :key="path"></router-view>
</transition>

Work with Alpine.js

Alpine x-transition must add enter and leave suffix, you have to add In and Out suffix after animation name.

<div x-show="open"
    x-transition:enter="fadeIn"
    x-transition:leave="fadeOut"
    style="animation-duration: .3s"
>...</div>

See also: https://github.com/alpinejs/alpine#x-transition

Attentions Seekers

To use Attentions, vue-animate.css provides a set of JS functions.

import { bounce } from '@asika32764/vue-animate';
import { ref } from 'vue';

const el = ref<HTMLElement>();

bounce(el.value);

Options

You could add animation properties to following parameters.

bounce(el.value, 300); // Durations 300ms
bounce(el.value, '.3s'); // Durations 0.3seconds
bounce(el.value, 300, { delay: 200 }); // Add duration and delay
bounce(el.value, { duration: 300, delay: 200 }); // Add duration and delay by options object
OptionTypeDescription
durationstring, numberCan be any CSS valid duration value.
delaystring, numberCan be any CSS valid duration value.
iterationCountstring, numberThe number of times to play.
directionnormal reverse alternate alternate-reverseThe animation playing direction.
fillModenone forwards backwards bothThe animation fill mode.

Contribution Guide

Clone project and install deps.

git clone [email protected]:asika32764/vue-animate.git
cd vue-animate
yarn install

Run:

yarn dev

Will launch a Vite dev server of the documentation site which the source file at src/docs. You can modify this site to test your code. (Do not push you test code.)

Build Lib

Run this command to build /dist files.

rollup -c

Build Docs

Run this command to build /docs files.

yarn build:docs

Sync from animate.css

This project is auto convert from animate.css animations, if animate.css release new animations, you can run this command to sync animations and auto generate source files.

yarn generate

版本与发布记录

@asika32764/vue-animate 共发布 3 个版本,首次发布于 2023/10/03;过去 12 个月发布了 0 个版本。

版本发布日期距今
3.0.2latest2023/10/213 年前
3.0.12023/10/033 年前
3.0.02023/10/033 年前

关于 @asika32764/vue-animate 的常见问题

如何安装 @asika32764/vue-animate?

在项目目录运行 npm install @asika32764/vue-animate,或使用 pnpm add / yarn add / bun add。

@asika32764/vue-animate 支持 TypeScript 吗?

支持。包内自带 TypeScript 类型声明(package.json 声明了 types 入口),安装后即可获得类型提示,无需再安装 @types 包。

@asika32764/vue-animate 支持 ESM 还是 CommonJS?

同时提供 ES Module 与 CommonJS 入口,import 和 require() 都可以使用,打包工具会自动选择合适的版本。

@asika32764/vue-animate 可以商用吗?

@asika32764/vue-animate 使用 MIT 许可。宽松许可:允许商业使用、修改和再分发,通常只需在分发时保留原版权与许可声明。以上为概括,不构成法律意见,请以许可原文为准。

@asika32764/vue-animate 的下载量有多少?

根据 npm 官方下载统计,@asika32764/vue-animate 在 2026/10/07 – 2026/11/05 这 30 天内被下载 5,547 次,日均约 185 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@asika32764/vue-animate 还在维护吗?

最新版本 3.0.2 发布于 2023/10/21(3 年前);至今共发布 3 个版本,其中过去 12 个月发布了 0 个;首次发布于 2023/10/03。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。