Coder Social home page Coder Social logo

Angular Docs about auto-animate HOT 5 OPEN

formkit avatar formkit commented on May 22, 2024
Angular Docs

from auto-animate.

Comments (5)

Waterstraal avatar Waterstraal commented on May 22, 2024 1

I created a quick POC:

import { AfterViewInit, Directive, ElementRef, Input } from '@angular/core';
import autoAnimate, { AutoAnimateOptions, AutoAnimationPlugin } from '@formkit/auto-animate';

@Directive({
  selector: '[auto-animate]'
})
export class AutoAnimateDirective implements AfterViewInit {
  @Input() options: Partial<AutoAnimateOptions> | AutoAnimationPlugin = {}

  constructor(private el: ElementRef) {}

  ngAfterViewInit(): void {
    autoAnimate(this.el.nativeElement, this.options);
  }
}

Works like a charm:

import { Component } from '@angular/core';

@Component({
  selector: 'app-root',
  template: `
    <ul auto-animate [options]="{duration: 500}">
      <li *ngFor="let item of items">{{item}}</li>
    </ul>
    <button (click)="this.items.push('🍒 Cherry')">Add fruit</button>
  `
})
export class AppComponent {
  items: string[] = ['🍎 Apple', '🍌 Banana', '🍓 Strawberry'];
}

from auto-animate.

justin-schroeder avatar justin-schroeder commented on May 22, 2024

That would be great. We don't plan to touch angular ourselves so it needs to be a submission from someone like yourself anyway :)

from auto-animate.

Waterstraal avatar Waterstraal commented on May 22, 2024

I also came looking for Angular support :)

To be fair, the docs do say this:

You can use it with React, Vue, Svelte, or any other JavaScript application

That claim needs an asterisk ;).

But it shouldn't be impossible to create an auto-animate Angular directive @danielehrhardt

from auto-animate.

danielehrhardt avatar danielehrhardt commented on May 22, 2024

I created a quick POC:

import { AfterViewInit, Directive, ElementRef, Input } from '@angular/core';
import autoAnimate, { AutoAnimateOptions, AutoAnimationPlugin } from '@formkit/auto-animate';

@Directive({
  selector: '[auto-animate]'
})
export class AutoAnimateDirective implements AfterViewInit {
  @Input() options: Partial<AutoAnimateOptions> | AutoAnimationPlugin = {}

  constructor(private el: ElementRef) {}

  ngAfterViewInit(): void {
    autoAnimate(this.el.nativeElement, this.options);
  }
}

Works like a charm:

import { Component } from '@angular/core';

@Component({
  selector: 'app-root',
  template: `
    <ul auto-animate [options]="{duration: 500}">
      <li *ngFor="let item of items">{{item}}</li>
    </ul>
    <button (click)="this.items.push('🍒 Cherry')">Add fruit</button>
  `
})
export class AppComponent {
  items: string[] = ['🍎 Apple', '🍌 Banana', '🍓 Strawberry'];
}

Wow Nice! Maybe you can create a Pull Request?

from auto-animate.

Waterstraal avatar Waterstraal commented on May 22, 2024

Sorry for the delay, I just got around for it. I created a PR that add Angular support.

from auto-animate.

Related Issues (20)

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.