Coder Social home page Coder Social logo

asika32764 / vue-animate Goto Github PK

View Code? Open in Web Editor NEW

This project forked from haydenbbickerton/vue-animate

1.4K 17.0 132.0 484 KB

A port of Animate.css for use with transitions in Vue.js 2.0 / 3.0 and Alpine.js.

Home Page: https://vue-animate.simular.co/

License: Other

JavaScript 7.85% TypeScript 31.49% HTML 3.44% CSS 41.25% Vue 15.97%
vue2 transition transition-animation animation vue-transition vue vuejs vuejs2 vue3 vue-animate

vue-animate's Introduction

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);

This function is very useful for adding some one-time animation to html element, for example, this is an incorrect password attentions.

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

if (!await checkPassword()) {
  headShake(passwordInput.value);
}

handshake

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
Option Type Description
duration string, number Can be any CSS valid duration value.
delay string, number Can be any CSS valid duration value.
iterationCount string, number The number of times to play.
direction normal reverse alternate alternate-reverse The animation playing direction.
fillMode none forwards backwards both The 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

vue-animate's People

Contributors

asika32764 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

vue-animate's Issues

No transitions working

Hi, I followed your example and got my transition working with bounceInLeft and bounceOutRight, but after that I tried using the other transitions and I found that none of them work. I am getting them from the list of supported animations.

Malformed css property

Hi,

I noticed a bug with the "make-transitions" mixin. The property animation-name is created with quotes and that is invalid css.

Here is a short gif showing the problem: GIF

To fix it, I simply removed the single quotes from the 4 animation-name property definitions.

Best regards,

Rui Freitas

v-show

Hi!
I'm trying to use with v-show:

`                    <transition
                            name="custom-classes-transition"
                            enter-active-class="bounceLeft-enter"
                            leave-active-class="bounceRight-leave" >
                           <div v-show="mode=='1'">
                               <componentName></componentName>    
                           </div>      
                        </transition>    `

Seems is not working.
Thanks in advance

Flippers

Hi,
Flippers are not in :

  • flip
  • flipInX
  • flipOutX
  • flipInY
  • flipOutY

Thanks

建议

如果能控制动画参数会更好。

Sass Version

Is there going to be an option for Sass as opposed to Less.

animation names different than animate.css?

Is there a reason why the animations are called differently compared to animate.css? I can't find fadeUp there, just fadeInUp or fadeOutUp.

Just asking out of curiousity.

Thanks!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.