Share Posted July 15, 2022 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 More sharing options...
Share Posted July 16, 2022 Sure, here's a solution that also gets rid of the need for jQuery: See the Pen poLRJyj?editors=0010 by GreenSock (@GreenSock) on CodePen Does that help? 1 Link to comment Share on other sites More sharing options...
Author Share Posted July 16, 2022 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. 2 Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now