Jump to content

Search In
  • More options...
Find results that contain...
Find results in...

SVG Foreach random order

Go to solution Solved by tailbreezy,

Recommended Posts

Hi all,


My SVG flower classes animate in the order given by the HTML = pink, blue, red, purple - can anyone please tell me how I could say - animate in a random order each time the page is loaded eg blue first, next time red first etc

See the Pen QWGJNbx by Juc1 (@Juc1) on CodePen

Link to post
Share on other sites



You can use one of gsap utilities.


let flower = gsap.utils.toArray(".flower");
let shuffled = gsap.utils.shuffle(flower)

   shuffled.forEach(item => {
       let stempath = item.querySelector(".stem");


  • Like 5
Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    No registered users viewing this page.