Jump to content
Search Community

Tweening the propertie of an object literal

bromel test
Moderator Tag

Go to solution Solved by Carl,

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

Good Evening

 

I am wanting to tween a property of a javascript object. For example I simply want to change Obj.coeficient.value to = 5.

Below is my object example.

var Obj = {
  coeficient:{
    type: "f",
    value:0.39
  },
  glowColor: {
    type: "g",
    value:5
  },
  power: {
    type: "a",
    value:2
  },
}

I have done a simple codepen to try and illustrate the problem. Any help will be extremely useful.

 

bromel

See the Pen evbYPX by w9914420 (@w9914420) on CodePen

Link to comment
Share on other sites

  • Solution

Thanks for the pen. A mere typo.

In your object you had coeficient but in all your TweenMax code you had coeficent.

 

update all your code to use coefficient and you are good;)

var Obj = {
  coefficient:{
    type: "f",
    value:0.39
  },
  glowColor: {
    type: "g",
    value:5
  },
  power: {
    type: "a",
    value:2
  },
}






TweenMax.to(Obj.coefficient, 5, {value:5,
   onUpdate:function(){
   console.log(Obj.coefficient.value)
   document.getElementById("log").innerHTML = Obj.coefficient.value;


}})
  • 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...