Jump to content
Search Community

The "vars" object.

SpaceMoney-01011000 test
Moderator Tag

Recommended Posts

Hey, guys. I'm trying to learn GSAP and I keep coming across the term "the vars object".

So, I've decided to read through the following documentation;
https://greensock.com/docs/v3/GSAP/Tween/vars#:~:text=.-,vars,class" {onComplete%3A func})%3B

I understand what a variable is, ( e.g. var myFoo = "foo") but I'm still not understanding what the "vars" object is. Is this term nomenclature specific to GSAP?

Is anyone willing to give me a simplified explanation of what this means in the context in which it's being used?

Thanks in advance!

Kind regards. 

Link to comment
Share on other sites

Sorry about any confusion there, @SpaceMoney-01011000. Yeah, I guess it's somewhat GSAP-specific in a sense. Think of it like a configuration object where all the properties go. Originally (and remember, that means back in 2008-ish), I just named the parameter "vars" because that's where all the variable stuff went. It's an object literal, like: 

gsap.to(".target", 
  // THIS IS THE VARS OBJECT:
  {x: 100, rotation: 180, ease: "elastic", onComplete: myFunc}
);

Does that clear things up? 

  • Thanks 1
Link to comment
Share on other sites

Awesome! Thanks!

I kind of picked up on that a bit from the contextual clues, but I wasn't completely sure of it. Thank you for taking the time to answer such a basic question.

I'm learning JS an GSAP simultaneously, so I get a little befuddled when trying to wrap my head around what's being taught in the documentation.

Nevertheless, I'm having a blast with GSAP. This is the perfect tool for molding the potential of online content. I'm finding it very inspirational.

  • Thanks 1
Link to comment
Share on other sites

37 minutes ago, SpaceMoney-01011000 said:

I'm learning JS an GSAP simultaneously, so I get a little befuddled when trying to wrap my head around what's being taught in the documentation.

Nevertheless, I'm having a blast with GSAP. This is the perfect tool for molding the potential of online content. I'm finding it very inspirational.

That's great to hear! I can't tell you how many people have said that they learned JavaScript by learning GSAP which worked very well for them because it made things much more "fun". Getting things to move in the browser is more inspiring that reading dry documentation about theoretical jargon and how Arrays work, blah, blah. But as you move along with GSAP, it sorta forces you to reach for those other things (like "what's an Array? Why are there quotes around some of these things? What's camelCase?"). 

 

Anyway, good luck on your learning journey. I'm glad to hear GSAP is providing some inspiration along the way. 🙌

  • Like 1
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...