Jump to content
Search Community

Uncaught TypeError: Cannot read property 'rotation' of undefined

smallio test
Moderator Tag

Warning: Please note

This thread was started before GSAP 3 was released. Some information, especially the syntax, may be out of date for GSAP 3. Please see the GSAP 3 migration guide and release notes for more information about how to update the code to GSAP 3's syntax. 

Recommended Posts

There's a few things amiss. Best thing to do in this case is to log out the values you are trying to use.

 

For instance

 

console.log(c) // "circle"
console.log(c[0]) // "c"

 

I don't think c or c[0] are what you are expecting them to be.

 

Also here: 
 

var rotation = c[0]._gsTransform.rotation + 3.6 * parseInt(drawVals.start);

 

You are trying to find a _gsTransform on a string (not a DOM element), but equally as important is that a DOM element ONLY gets a _gsTranform AFTER you set or animate one of its transform values. 

 

 

 

Hopefully that helps you tweak your approach. If you need more help, let us know.

 

 

 

 

  • Like 3
Link to comment
Share on other sites

Thanks for the explanation @carl. I managed to get it working via another method :D 

 

See the Pen gjVxrJ by smallio (@smallio) on CodePen

 

It would, however, be awesome to know what is different then this little pen which sahil helped me on a while back. The code is essentially the same for that part yet when it's not used in a function it goes haywire!

 

See the Pen xWxgwP?editors=0010 by smallio (@smallio) on CodePen

 

What am I missing here lol?

 

Many thanks,

Smallio

Link to comment
Share on other sites

1 minute ago, Carl said:

In Sahil's demo jQuery is being used to create a jQuery object based on the selector string

https://learn.jquery.com/using-jquery-core/jquery-object/

 


var c = $('#circle'); // jQuerey object
//is much different than
var c = ("circle"); // a string

 

 

 

ahhhh obviously!!! sorry blonde moment, aha. really appreciate the explanation :)

  • Like 1
Link to comment
Share on other sites

  • 9 months later...

This error occurs in Chrome Browser when you read a property or call a method on an undefined object . Uncaught TypeError: Cannot read property of undefined  error is probably easiest to understand from the perspective of undefined, since undefined is not considered an object type at all (but its own undefined type instead), and properties can only belong to objects within JavaScript. There are a few variations of this error depending on the property you are trying to access. Sometimes instead of undefined it will say null.

 

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