Jump to content
Search Community

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

ulrich sinn
Posted

It appears that the declaration file has:

 

time(value:number, suppressEvents?:boolean):any;

 

but should it rather be:

 

time(value?:number, suppressEvents?:boolean):any;

 

since it functions as a getter as well?

 

the web storm compiler throws an error in the first case, not in the second.

Posted

Hi

 

We do not maintain any typescript files. 

I think you will need to contact the person that provided the file.

  • Like 1
Posted

Those definitions are out of date. I'm working on a new set, but until then, you're going to have to make due with what's available. No getter or overloads were included, so you're going to have to change those. 

// Getter
time(): number;

// And one of these setters
time(value: number, suppressEvents?: boolean): TweenLite;
time(value: number, suppressEvents?: boolean): TweenMax;
time(value: number, suppressEvents?: boolean): TimelineLite;
time(value: number, suppressEvents?: boolean): TimelineMax;

You don't return any because then you can't chain your method calls with the correct type. TypeScript currently does not support returning something like this or self in a definition, so you have to manually write out a return for each type of GSAP instance (TweenLite, TweenMax, etc...)

 

http://stackoverflow.com/questions/29309735/method-chaining-when-extending-typescript-classes

  • Like 1
Posted

Here's an example using TweenLite

 

http://www.typescriptlang.org/Playground#src=type%20Target%20%3D%20Object%7CObject%5B%5D%3B%0A%0Ainterface%20CSSPlugin%20%7B%0A%09x%3F%3A%20number%7Cstring%3B%0A%09y%3F%3A%20number%7Cstring%3B%0A%09scaleX%3F%3A%20number%7Cstring%3B%0A%09scaleY%3F%3A%20number%7Cstring%3B%0A%09%2F%2F%20more...%0A%7D%0A%0Ainterface%20TweenLiteVars%20extends%20CSSPlugin%20%7B%0A%09delay%3F%3A%20number%3B%0A%09paused%3F%3A%20boolean%3B%0A%09immediateRender%3F%3A%20boolean%3B%0A%09%2F%2F%20more...%0A%7D%0A%0Adeclare%20class%20TweenLite%20%7B%0A%09%0A%09static%20defaultOverwrite%3A%20string%3B%0A%09%0A%09data%3A%20any%3B%0A%09target%3A%20Object%7CObject%5B%5D%3B%09%0A%09%0A%09constructor(target%3A%20Target%2C%20duration%3A%20number%2C%20vars%3A%20TweenLiteVars)%3B%0A%09%0A%09static%20to(target%3A%20Target%2C%20duration%3A%20number%2C%20vars%3A%20TweenLiteVars)%3A%20TweenLite%3B%0A%09%0A%20%20%20%20time()%3A%20number%3B%0A%20%20%20%20time(value%3A%20number%2C%20suppressEvents%3F%3A%20boolean)%3A%20TweenLite%3B%20%20%20%20%0A%7D%0A%0A%2F%2F%20SOME%20SIMPLE%20TESTS...%0Avar%20element%20%3D%20document.getElementById(%22foo%22)%3B%0A%0A%2F%2F%20Good%0Avar%20tween1%20%3D%20TweenLite.to(element%2C%201%2C%20%7B%20x%3A%20200%2C%20paused%3A%20false%20%7D)%3B%0Avar%20time%20%3D%20tween1.time()%20%2B%202%3B%0Atween1.time(0.5%2C%20false)%3B%0A%0A%2F%2F%20Create%20some%20errors%0Avar%20tween2%20%3D%20TweenLite.to(element%2C%20%221%22%2C%20%7B%20x%3A%20200%20%7D)%3B%0Avar%20tween3%20%3D%20TweenLite.to(element%2C%201%2C%20%7B%20x%3A%20false%20%7D)%3B%0Avar%20tween4%20%3D%20TweenLite.to(element%2C%201%2C%20%7B%20paused%3A%20%22false%22%20%7D)%3B%0Avar%20length%20%3D%20tween1.time().length%3B%0A

  • Like 1

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