dimanche 30 août 2020

AnimeJs random happens only once

I made a function to randomly pick a color for each element in the animejs but it doesn't work as expected. the random colors are picked only for the initiation of animation and on loop the colors don't change, is there any workaround to this?

here's what i have:

anime({
    targets: '.jumperTexts',
    scale: [
        {value: [0.5 , 1], easing: 'easeInOutBounce', duration: 800}
      ],
    backgroundColor:function(){ 
      let letters = "3456789ABCDEF"; 
      let color = '#'; 
      for (let i = 0; i < 6; i++) 
       color += letters[(Math.floor(Math.random() * 13))]; 

      return color;},
    width:['80px','80px'],
    height:['80px','80px'],
    borderRadius: ['50%','50%'],
    duration: 1200,
    endDelay: 1000,
    delay:anime.stagger(50),
    direction: 'alternate',
    loop: true
  });



Aucun commentaire:

Enregistrer un commentaire