Jump to content
Search Community

Combining child element classes when using toArray & FLIP

TimTh test
Moderator Tag

Recommended Posts

I am struggling to figure out how to write the most efficient code with toArray and FLIP and hoping someone can point me in the right direction. I'm using toArray to find all classes for a set of divs, then using FLIP to animate the contents of those divs via toggleclass on click. The contents are child elements, which I'm identifying within each instance using JQ find. My problem is that I'd like to write one Flip.getState, one toggleClass, and one Flip.from statement to cover all the child class animations, but my coding skills are too shaky to know how to do that since the class names are within the toArray. The linked CodePen is a working example using inefficient, duplicate statements, with a comment showing those I'd like to consolidate.  Apologies, I know this is probably more of a pure JS/JQ question than GSAP-specific. Thank you!

See the Pen poLNMXo by TimTh (@TimTh) on CodePen

Link to comment
Share on other sites

Thank you, Jack. This is very helpful. It was the square bracket notation that I was missing. Your solution also works if I leave in the JQuery and just use square brackets with Flip.getState, which also eliminates the second Flip.from statement. I really appreciate your taking the time to code the answer for me! Awesome.

  • Like 2
Link to comment
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.
×
×
  • Create New...