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

ng-auto-animate

v0.3.2

Published

Add motion to your apps with a single line of code. An Angular Directive to use FormKit's auto-animate library.

Downloads

355

Readme

ng-auto-animate

An Angular Directive to use FormKit's auto-animate library within Angular projects.

Highlights

  • ✅ Standalone Directive, for Angular v14 and above. Tested on Node 18.x, but should work on previous versions.
  • ✅ Custom InjectionToken for configuring global settings and plugins.

Why a new wrapper library?

A publishable library for Angular needs ng-packagr and Angular CLI for proper scaffolding and finalized formatting. Migrating the repository structure for auto-animate is a non-trivial task and would need an unbiased build system like Nx (which I am using here) or some other similar tool.

Justin Schroeder, the creator of auto-animate, has been supportive towards contributions for Angular integration, but he does not work with Angular and is unable to work towards this actively. I, too, would not be able to do much in his shoes, especially when it requires replacing all build actions, scripts and the project structure, all to support a single framework.

If there is a simpler solution, I would be willing to submit a PR with my changes here to the original project, especially the support for global options/plugin via an InjectionToken.

Installation

  1. Install the peer dependency.

    npm i @formkit/auto-animate
  2. Install this package.

    npm i ng-auto-animate

Usage

Principle

Add the directive to the parent tag, within which DOM elements are being shown or hidden dynamically.

Adding the directive to the same tag which is being hidden will do nothing since it will look for changes in child nodes only.

Import Path

Import and add the directive to your module or standalone component's imports array.

import { NgAutoAnimateDirective } from 'ng-auto-animate'; 

Variants

  1. Default usage. This uses the default values configured by @formkit/auto-animate.

    <article auto-animate>
      <p *ngFor="let paragraph of paragraphs">
        {{ paragraph }}
      </p>
    </article>
  2. Pass one-off options. Inline options will completely replace/override the default options.

    <article [auto-animate]="{ duration: 750 }">
      <p *ngFor="let paragraph of paragraphs">
        {{ paragraph }}
      </p>
    </article>
  3. Global options. The ideal place to configure common settings across your app.

    // src/app/app.config.ts
    import { ApplicationConfig } from '@angular/core';
    import { GLOBAL_AUTO_ANIMATE_OPTIONS } from 'ng-auto-animate';
    
    export const appConfig: ApplicationConfig = {
      providers: [
        {
          provide: GLOBAL_AUTO_ANIMATE_OPTIONS,
          useValue: {
            duration: 750,
            easing: 'ease-out',
            // etc.
          },
        },
        // other providers
      ],
    };
    
    // main.ts
    import { bootstrapApplication } from '@angular/platform-browser';
    import { appConfig } from './app/app.config';
    import { AppComponent } from './app/app.component';
    
    bootstrapApplication(AppComponent, appConfig).catch((err) =>
      console.error(err)
    );
    <article auto-animate> <!-- Default usage -->
      <p *ngFor="let paragraph of paragraphs">
        {{ paragraph }}
      </p>
    </article>
  4. Custom plugins. Same support as @formkit/auto-animate.

    See the example here in the demo app for a "bouncy" effect.

    customPlugin: AutoAnimationPlugin = (...) => {...};
    <article [auto-animate]="customPlugin">...</article>

Missing support for something?

Go through existing issues if your problem is already being tracked; otherwise, raise an issue!

License

MIT.

Built by Ajit Panigrahi. Original library by Justin Schroeder and many contributors.


This library was generated with Nx.