Coder Social home page Coder Social logo

hhy5277 / ng-animate Goto Github PK

View Code? Open in Web Editor NEW

This project forked from jiayihu/ng-animate

0.0 1.0 0.0 1.42 MB

๐ŸŒ™ A collection of cool, reusable and flexible animations for Angular 4.2+

Home Page: https://jiayihu.github.io/ng-animate/

License: MIT License

JavaScript 5.15% TypeScript 80.13% CSS 1.35% HTML 13.37%

ng-animate's Introduction

๐ŸŒ™ ng-animate

npm

ng-animate is a collection of cool, reusable and flexible animations for Angular. It implements all the animations in animate.css, but with the power and flexibility of Angular animations instead of CSS.

Note: the library requires Angular 4.2+, which introduced different new animation APIs needed by ng-animate.

Demo

The demo of the animations is available at https://jiayihu.github.io/ng-animate/.

Usage

npm install ng-animate --save

Example

Import the animation from the package and pass it to your Angular component using useAnimation:

// my-component.component.ts
import { trigger, transition, useAnimation } from '@angular/animations';
import { bounce } from 'ng-animate';

@Component({
  selector: 'my-component',
  templateUrl: 'my-component.component.html',
  animations: [
    trigger('bounce', [transition('* => *', useAnimation(bounce))])
  ],
})
export class MyComponent {
  bounce: any;
}
<!-- my-component.component.html -->
<div [@bounce]="bounce"></div>

Note: Make sure to have included BrowserAnimationsModule in your AppModule and the web-animation.js polyfill.

It's also possible to import only a subset of the animations:

import { bounce } from 'ng-animate/lib/bouncing';

Animation params

All the animations provided by ng-animate support at least two optional params timing and delay to specify the animation duration and delay. Default value for timing is usually 1s and 0s for delay.
You can pass the params object using the Javascript API or within the component template:

@Component({
  selector: 'my-component',
  templateUrl: 'my-component.component.html',
  animations: [
    trigger('bounce', [transition('* => *', useAnimation(bounce, {
      // Set the duration to 5seconds and delay to 2seconds
      params: { timing: 5, delay: 2 }
    }))])
  ],
})
export class MyComponent {}

Using a template can achieve the same result, but you'll have access to the component context:

<div [@bounce]="{ value: bounce, params: { timing: myTiming || 5, delay: myDelay || 2 } }"></div>

Animations

All the animations are organized by their group. Many of them have additional params other than timing/delay: refer to Advanced Usage for more details. Nevertheless you can probably ignore them if you're happy with how they are by default.

Attention seekers

  • bounce
  • flash
  • pulse
  • rubberBand
  • shake
  • swing
  • tada
  • wobble
  • jello

Bouncing

  • bounceIn
  • bouceOut. Additional param: scale

The following bouncing animations have additional params a, b, c, d for translate

  • bounceInDown
  • bounceInLeft
  • bounceInRight
  • bounceInUp
  • bounceOutDown
  • bounceOutLeft
  • bounceOutRight
  • bounceOutUp

Fading

All fading animations have additional params fromOpacity, toOpacity for opacity transition and a, b for translate.

  • fadeIn
  • fadeInDown
  • fadeInLeft
  • fadeInRight
  • fadeInUp
  • fadeOut
  • fadeOutDown
  • fadeOutLeft
  • fadeOutRight
  • fadeOutUp

Sliding

Sliding animations are basically fading animations without a change of opacity. They can also receive the same params.

  • slideInDown
  • slideInLeft
  • slideInRight
  • slideInUp
  • slideOutDown
  • slideOutLeft
  • slideOutRight
  • slideOutUp

Flippers

  • flip
  • flipInX
  • flipInY
  • flipOutX
  • flipOutY

LightSpeed

  • lightSpeedIn
  • lightSpeedOut

Rotating

All rotating animations have additional params fromOpacity, toOpacity for opacity transition, origin for transform-origin and degrees for rotate3d.

  • rotateIn
  • rotateInDownLeft
  • rotateInDownRight
  • rotateInUpLeft
  • rotateInUpRight
  • rotateOut
  • rotateOutDownLeft
  • rotateOutDownRight
  • rotateOutUpLeft
  • rotateOutUpRight

Specials

  • jackInTheBox
  • hinge
  • rollIn
  • rollOut

Zooming

  • zoomIn
  • zoomOut

The following zooming animations have additional params a, b for translate

  • zoomInDown
  • zoomInLeft
  • zoomInRight
  • zoomInUp
  • zoomOutDown
  • zoomOutLeft
  • zoomOutRight
  • zoomOutUp

Advanced params

Many of the animations support also other params like scale, fromOpacity, toOpacity and much more, allowing extremely flexible usage and customisation if you're not happy with default values.

Single letters like a, b, c, d are used for the steps of some animations: a is the starting value, d is the ending.
The animated property they refer to depends on the animation and the direction: usually translate on axis Y from -Down/-Up, axis X for -Left/-Right.

useAnimation(bounceInDown, {
  params: {
    timing: 5,

    // Specify granular values for `translate` on axis Y during 'bounceInDown' 
    a: '-3000px',
    b: '25px',
    c: '-10px',
    d: '5px',
  }
})

ng-animate's People

Contributors

amitport avatar jiayihu avatar

Watchers

 avatar

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.