I am working on implementing the following anime.JS effect on my site and having trouble manipulating the javascript to accommodate multiple lines of text. My desired output is that line one animates then fades out, line 2 animates etc.
https://tobiasahlin.com/moving-letters/#11
<script>
// Wrap every letter in a span
var textWrapper = document.querySelector('.ml11 .letters');
textWrapper.innerHTML = textWrapper.textContent.replace(/([^\x00-\x80]|\w)/g, "<span class='letter'>$&</span>");
anime.timeline({loop: true})
.add({
targets: '.ml11 .line',
scaleY: [0,1],
opacity: [0.5,1],
easing: "easeOutExpo",
duration: 700
})
.add({
targets: '.ml11 .line',
translateX: [0, document.querySelector('.ml11 .letters').getBoundingClientRect().width + 10],
easing: "easeOutExpo",
duration: 700,
delay: 100
}).add({
targets: '.ml11 .letter',
opacity: [0,1],
easing: "easeOutExpo",
duration: 600,
offset: '-=775',
delay: (el, i) => 34 * (i+1)
}).add({
targets: '.ml11',
opacity: 0,
duration: 1000,
easing: "easeOutExpo",
delay: 1000
});
</script>
I'd like the output to look something like this where 3 separate lines are displayed one after another - https://codepen.io/dsr/pen/mdJXEdP
How should I manipulate the JS code and what HTML classes I am using to get this effect?
you can do it with interval function, here is the example:
https://jsfiddle.net/3ux2jkpq/