I love the animejs libary form: https://github.com/juliangarnier/anime It fast, clear and easy to implement, except in Ionic of a Angular project.
I've take a look to the post: anime.js not working in Ionic 3 project but, it doenst work for me.
The image (who I what to animate) doens't animate.
Does anybody has this working? And please share a solution?
What I've done so far:
- Install animejs with npm: the package.json is updated with: "animejs": "^2.2.0"
- Animejs is availible in the node_modules
- With a custom copy-lib the anime.min.js is loaded in the index.html, see:
const existingConfig = require('../node_modules/@ionic/app-scripts/config/copy.config'); module.exports = Object.assign(existingConfig, { copyFontawesomeFonts: { src: ['{{ROOT}}/node_modules/font-awesome/fonts/**/*'], dest: '{{WWW}}/assets/fonts' }, copyFontawesomeCss: { src: ['{{ROOT}}/node_modules/font-awesome/css/font-awesome.min.css'], dest: '{{WWW}}/assets/css' }, copyAnimeJS: { src: ['{{ROOT}}/node_modules/animejs/anime.min.js*'], dest: '{{WWW}}/assets/js' }, } );
The index.html looks like:
...
<!-- Font-awesome --> <link href="assets/css/font-awesome.min.css" rel="stylesheet"/> <!-- Anime JS --> <link href="assets/js/anime.min.js" rel="stylesheet"/>
...
The anime.min.js is available in the index.html
I import the amine in my login.ts file like:
import { Component } from '@angular/core'; import { IonicPage, NavController, NavParams } from 'ionic-angular'; import * as anime from 'animejs'; ...
Load it in the constructor:
anime({ targets: '#authImg', translateY: -50, elasticity: 800, duration: 2500, direction: 'alternate', easing: 'easeInOutCubic', loop: true });
Which have to animate the following html:
<img src="assets/img/auth.png" alt="" id="authImg" />
But nothing happened...