Comments (5)
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.
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.
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.
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.
Sorry for the delay, I just got around for it. I created a PR that add Angular support.
from auto-animate.
Related Issues (20)
- Omi supports it, this's a great project HOT 1
- Memory Leak
- Bug when deleting element of the array in React 18
- Inconsistent jumping inside flex item HOT 1
- Not working HOT 4
- Vue Virtual Scroller
- Wrong arguments order in AutoAnimationPlugin declaration
- Animate across lists? Across all elements inside a `ul`?
- How should I use fixed centering layout? HOT 1
- Incorrect rounding of element sizes while animating HOT 2
- When the page is refreshed, the component has no animation.
- Vue useAutoAnimate not working with v-if
- does not provide an export named 'autoAnimate'
- Animation starting coords are buggy when the container has transitioned positions
- How to add auto-animate to custom components (NuxtUI) HOT 1
- Headless UI + Auto-Animate | Issue with auto-animate conflicting
- nuxt3 3.10.3 does not provide an export named 'autoAnimate' HOT 1
- I added the element from the front but the animation still appears from the last one HOT 1
- React.Children.map issue HOT 1
- How to animate single element? HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from auto-animate.