Jump to content
GreenSock

Search In
  • More options...
Find results that contain...
Find results in...
Sanprieto

is it possible to access to time duration in on Update Param?

Go to solution Solved by akapowl,

Recommended Posts

First of all congratulations, GSAP is extraordinary !!
I'm beginner in this. I would like to access to time's property ( duration tween ) in onUpdateParam()

Something like this :

this.parent._time


(And I can't find the main object here... )726877499_Capturadepantalla2020-10-21alas15_58_46.png.12a1915496f1c07c9d65a2089d94f245.png

Link to comment
Share on other sites

Just noting that this refers to the tween in an onUpdate if you don't use an arrow function so you don't need a variable reference to the tween:

onUpdate: function() {
  console.log(this.time());
}

 

  • Like 3
Link to comment
Share on other sites

On 10/21/2020 at 4:28 PM, akapowl said:

Hey @Sanprieto - welcome to the forums.

 

There is .time()

 

Is this what you're looking for?

 

 

 

 

Totally yes !!
Thank you so much.
following your example, can you access to 'box' in onUpdate ?

Link to comment
Share on other sites

12 minutes ago, ZachSaucier said:

Just noting that this refers to the tween in an onUpdate if you don't use an arrow function so you don't need a variable reference to the tween:


onUpdate: function() {
  console.log(this.time());
}

 

okay thanks for advice!!

Link to comment
Share on other sites

3 minutes ago, Sanprieto said:

can you access to 'box' in onUpdate ?

Sure. 

onUpdate: function() {
  console.log(this.time(), this.targets()[0])
}

 

  • Like 2
Link to comment
Share on other sites

3 minutes ago, ZachSaucier said:

Sure. 


onUpdate: function() {
  console.log(this.time(), this.targets()[0])
}

 

I'm working with three.js and the object is a mesh and with gsap animation the position. But I want to access to the mesh ( 3D object)
 

    gsap.to( object3D.position, { duration: 10, motionPath: {
       path: gsapPath,
       type:'cubic',
       },onUpdate: this.runGsap, onUpdateParams: [ object3D, this.startHSL, this.sizeHSL, 10 ]
    })

I pass like parameter object3D in onUpdateParams but I think It isn't necessary. In this case with targets[0] I have the vectors of position.

 

Link to comment
Share on other sites

21 hours ago, Sanprieto said:

I'm working with three.js and the object is a mesh and with gsap animation the position. But I want to access to the mesh ( 3D object)
 


    gsap.to( object3D.position, { duration: 10, motionPath: {
       path: gsapPath,
       type:'cubic',
       },onUpdate: this.runGsap, onUpdateParams: [ object3D, this.startHSL, this.sizeHSL, 10 ]
    })

I pass like parameter object3D in onUpdateParams but I think It isn't necessary. In this case with targets[0] I have the vectors of position.

 

 

I guess GSAP is animating the property's position of the object. It isn't a problem to pass object like parameter. 


Thank you very much for your answers !!!!

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