For those who encounter this problem from 2020, there is a simpler way to solve this problem in the latest versions of Angular:
- Import the AOS library:
npm i -s aos
- Import the typing into TypeScript:
npm i -D @types/aos
- Import CSS in the global style (Probably src/styles.scss):
@import "~aos/dist/aos.css";
- Start AOS on your project's root component (Probably app-component.ts)
import * as AOS from 'aos';
...
export class AppComponent implements OnInit {
ngOnInit(): void {
AOS.init();
}
}
- Be happy:
<img data-aos="animation_name" src="..."/>
e.g.:
<img data-aos="fade" src="..."/>
Animation names list: https://github.com/michalsnik/aos/tree/v2#-animations
Advanced settings: https://github.com/michalsnik/aos/tree/v2#-advanced-settings