Jump to content
Search Community

gsap 3 onUpdate : Access to tween object

Priska test
Moderator Tag

Recommended Posts

Before I could use the tween.target property to access the object,


 

this.innerTweenID = TweenMax.to(this.obj, 1.2, {
  y: this.scrollTo,
  ease: Power4.easeOut,
  onUpdate: tween => {
    const scrollTop = Math.round(tween.target.y)
  }
})

 

How about now ?

The documentation is full of examples but never talk about that point....

 

PLEASE HELP !

Link to comment
Share on other sites

You can access the target by using this.targets() in GSAP 3 (arrow functions are always locked into the scope they're created then so don't use them if you're trying to use this). So you can do this.targets()[0] to get your element:

 

onUpdate: function() {
  const scrollTop = Math.round(gsap.getProperty(this.targets()[0], "y"));
  console.log(scrollTop);
  //...
},

.getProperty() could also be used as elegantseagulls mentioned.

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