npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

ack-angular-fx

v5.0.2

Published

Angular animations made easier

Downloads

205

Readme

Description

Angular animations made easy. Example Page

hire me npm version npm downloads Dependency Status

animated gif

Angular 5.2.0+ required

Install

Requirements

Since you're using Angular, the following are expected to already be installed:

  • reflect-metadata
  • @angular/core
  • @angular/animations

install command:

npm install ack-angular-fx --save-dev

Include

Animations must be injected into your components and this is how to do that

import { animations } from "ack-angular-fx";
import { Component } from "@angular/core"

@Component({
  animations:animations,
  template:`
    <div *ngIf="boolean" [@fadeInOutUp]="boolean">
      ...
    </div>
    <button (click)="boolean=!boolean">
      hide or show
    </button>
  `
}) export class AppComponent

Browser Compatibility

All good!

Angular animations have come a long way. In the past, they didn't work in Safari without including additional libraries. Now, all animations appear to be working anywhere that Angular could be run.

Examples

View interactive example page here.

Robust Example

This example has pretty much everything needed to boot

NOTE: AckFxModule, in code below, is only needed IF directive fx-tracker being used for back-n-forth swap animation tracking

import "zone.js"
import "reflect-metadata"
import { platformBrowserDynamic } from "@angular/platform-browser-dynamic"
import { NgModule, Component } from "@angular/core"
import { BrowserModule } from "@angular/platform-browser";
import { BrowserAnimationsModule } from "@angular/platform-browser/animations"

import { animations } from "ack-angular-fx";

//NOTE: This line only needed IF directive fx-tracker used (back-n-forth swap animations)
import { AckFxModule } from "ack-angular-fx";
  
import { supportDocument } from "ack-angular-fx/web-animations.min"

supportDocument( document )//cross browser fx support

@Component({
  animations:animations,
  template:`
    <div *ngIf="boolean" [@rotateInOut]="boolean">
      ...
    </div>
    <button (click)="boolean=!boolean">
      hide or show
    </button>
  `
}) export class AppComponent

@NgModule({
  imports: [
    BrowserModule,
    BrowserAnimationsModule,
    AckFxModule//NOTE: This line only needed IF directive fx-tracker used (back-n-forth swap animations)
  ],
  declarations: [ AppComponent ],
  bootstrap: [ AppComponent ]
}) export class AppModule {}


platformBrowserDynamic().bootstrapModule(AppModule)

Params Example

The configuration options available to define for animations

<div [@zoomInOut]="{value:boolean, params:{time:'2000ms 0 linear'}}">
  ...
</div>

Learn more about Angular animation timing here

Stagger

Offset multiple animations using Angular 4.2.4 or greater

Currently, staggering animations using ack-angular-fx, is controlled by a parent stagger definition and child animations subscribing to that via the css class "childFx"

Stagger Items Example

A parent container staggering child animations whenever the array adds or removes elements

<div [@childStag]="array.length">
  <div
    *ngFor = "let x of array"
    [@rotateInOut] = "1"
  >
    <div>
      ngFor loop with animations for each
    </div>
  </div>
</div>

Stagger Table Rows Example

A table element staggering row animations whenever "rowStaggers" variable changes value

<table style="width:100%" [@childStag]="array.length">
  <ng-container *ngFor="let x of array">
    <tr [@bounceInOut]="array.length" style="background-color:#CCC">
      <td>{{ x }}</td>
      <td>Item Row {{ x }}</td>
    </tr>
  </ng-container>
</table>

Supported Animations

  • fadeIn
    • fadeInDown, fadeInLeft, fadeInRight, fadeInUp
  • fadeOut
    • fadeOutDown, fadeOutLeft, fadeOutRight, fadeOutUp
  • fadeInOut
    • fadeInOutDown, fadeInOutLeft, fadeInOutRight, fadeInOutUp
  • bounceIn
    • bounceInDown, bounceInLeft, bounceInRight, bounceInUp
  • bounceOut
    • bounceOutDown, bounceOutLeft, bounceOutRight, bounceOutUp
  • bounceIn
    • bounceInOutDown, bounceInOutLeft, bounceInOutRight, bounceInOutUp
  • rotateIn
    • rotateInDownLeft, rotateInDownRight, rotateInUpLeft, rotateInUpRight
  • rotateOut
    • rotateOutDownLeft, rotateOutDownRight, rotateOutUpLeft, rotateOutUpRight
  • rotateInOut
    • rotateInOutDownLeft, rotateInOutDownRight, rotateInOutUpLeft, rotateInOutUpRight
  • zoomIn
    • zoomInDown, zoomInLeft, zoomInRight, zoomInUp
  • zoomOut
    • zoomOutDown, zoomOutLeft, zoomOutRight, zoomOutUp
  • zoomInOut
    • zoomInOutDown, zoomInOutLeft, zoomInOutRight, zoomInOutUp
  • slideInDown, slideInLeft, slideInRight, slideInUp
  • slideOutDown, slideOutLeft, slideOutRight, slideOutUp
  • slideInOutDown, slideInOutLeft, slideInOutRight, slideInOutUp

see online demo https://ackerapple.github.io/ack-angular-fx

Prebuild Fxs to Single File

Known as the prefx process, ack-angular-fx has cli commands to bundle animations to file

This often helps with bundling issues and Angular AOT compilation

Example Compile All Animations to One File

Step 1 : Add the following to your package.json scripts

"scripts":{
  "build:prefx": "ack-angular-fx --out ./src/prefx.ts"
}

Step 2 : Now, run the following in a command prompt terminal

npm run build:prefx

After the above command you should now see a prefx.ts file in your src folder

Step 3 : Import your compiled .ts file and apply to component(s)

import { animations } from "./prefx"
import { Component } from "@angular/core"

@Component({
  selector: 'app',
  template: '<div *ngIf="a==1" [@fadeInUp]="true">hello world</div>',
  animations: animations
})

Work on This Project

Everything in this topic is run in an command prompt terminal

Clone this project

git clone https://github.com/AckerApple/ack-angular-fx

Dev Fast Project Watching

npm run watch

Build before commit

npm run build

Credits

A special thank you goes out to yuyang041060120 for creating ng2-animate and for taking too long to respond to my pull request, which has led to the birth of ack-angular-fx.

Table of Contents

Resources