I installed anime js through npm and followed all the steps on the github, however the text is not animating
Here are my HTML and JS codes
HTML:
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" href="app.css">
<title>Anime Demo</title>
</head>
<body>
<script src="index.js"></script>
<script src="node_modules/animejs/lib/anime.min.js"></script>
<div><h1>This is a header!!</h1></div>
</body>
</html>
JS:
let anime = require('animejs')
let div = document.querySelectorAll('div')
anime({
targets: div,
translateX: 250,
rotate: '1turn',
backgroundColor: '#FFF',
duration: 800
});
According to the documentation of
targets
, it needs to be a selector, i.e aString
.So your code should be: