Jump to content
Search Community

GSAP Flip is not working

momo12 test
Moderator Tag

Go to solution Solved by akapowl,

Recommended Posts

Hi guys

 

GSAP flip is not working as I expected. 

1- First there is an error around the line " imagewr.classList.toggle("reorder");" 

Uncaught TypeError: Cannot read properties of undefined (reading 'toggle')

2- Second why the changes to the .img-wr-2 are not being applied?

3- Why the the class name state changes without any aniamtion?

See the Pen ZEoVeyr by emdesigner-or (@emdesigner-or) on CodePen

Link to comment
Share on other sites

  • Solution

Hey there,

 

Flip appears to be working fine - you are just making some general JS mistakes; e.g. you're creating multiple arrays, and in your forEach loop you are then trying to toggle the class on an array (of arrays), which doesn't work like that. That's what the error that you're encountering is about.

 

Also, on line 11, you've got a comma that will still be causing an unexpected toke error in your console if you had resolved that first problem.

 

Here are some helpful ressources and your example working. Hope it will help.

 

https://developer.mozilla.org/en-US/docs/Web/API/Element/classList

https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array

https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/forEach

 

See the Pen qBYwbZX by akapowl (@akapowl) on CodePen

 

 

  • Like 3
Link to comment
Share on other sites

19 minutes ago, akapowl said:

Hey there,

 

Flip appears to be working fine - you are just making some general JS mistakes; e.g. you're creating multiple arrays, and in your forEach loop you are then trying to toggle the class on an array (of arrays), which doesn't work like that. That's what the error that you're encountering is about.

 

Also, on line 11, you've got a comma that will still be causing an unexpected toke error in your console if you had resolved that first problem.

 

Here are some helpful ressources and your example working. Hope it will help.

 

https://developer.mozilla.org/en-US/docs/Web/API/Element/classList

https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array

https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/forEach

 

 

 

 

 

Thanks a lot man!

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...