Closed saiyaff closed 6 years ago
Frankly, I'm not very familiar with Angular or what might be going on in your particular project, but have you tried not including TweenMax in your scripts array at all or pointing it at the root, uncompressed file instead of the minified one?:
"../node_modules/gsap/TweenMax"
?
Thanks for the response @jackdoyle
"But have you tried not including TweenMax in your scripts array at all or pointing it at the root"
If this is saying about adding the library in the index.html in the script element, yes. The same error occurs.
I've tried "../node_modules/gsap/TweenMax.js"
or "../node_modules/gsap/src/uncompressed/TweenMax.js"
also and no luck with that.
Hm, I'm not quite sure what to tell you. I wish I had more time to get up to speed with Angular and the build process you're using, but I know that plenty of folks are using GSAP with Angular, Webpack, various other build systems, etc. so my guess is that there's something a little off with your configuration or something. I wish I had a better answer for you. Perhaps someone else has some insight to offer. Feel free to post in the GreenSock forums where you'll have a better chance of some experts chiming in. https://greensock.com/forums/
I've been using Angular2 for a while now and it can get super finicky with imports and your setup.
The first error is a typescript error, I'm not sure if you are just using the npm library for the types but there is also : @types/gsap
that you should add as well.
Also, if you can do the import
you shouldn't also add it to the scripts. From your link:
Once you import a library via the scripts array, you should not import it via a import statement in your TypeScript code (e.g. import * as $ from 'jquery';)...
Checkout this page on 3d party libs from the CLI
I looked into the typescript and I may have found where the issue is on problem 1.
For tweenLites
the to()
method has a different pattern:
/** Static method for creating a TweenLite instance that animates to the specified destination values (from the current values). */
static to(target: any, duration: number, vars: any): TweenLite;
/** Static method for creating a TweenMax instance that animates to the specified destination values (from the current values). */
static to(target: {}, duration: number, vars: TweenConfig): TweenMax;
It looks like it doesn't like your vars object having unknown properties. Not totally sure what you can do besides create your own .ts file, but it seems like everyone should be having the same TS error.
As to the second error in your console, my guess is there is confusion between your imported version of gsap and your global version. I would do a console.log('window', window)
and see what globals are being loaded and when...
Hope that leads you in the right direction!
@msaiyaff @DennisSmolek Those are not official definitions, and should not be used. For now, you use these. https://greensock.com/forums/topic/16395-gsap-business-green-in-angular-2/#comment-74644
Using the Angular CLI works fine. You should not use import with GSAP if you add it to the global scripts. Choose one or the other. If you have anymore questions, ask on the forum. Github issues should be used for tracking bugs.
Thanks!
Ah my bad sorry. Is there anything you can do to get those old ones off @types
? That's generally the primary method even angular is pushing so the problem may come up more.
Ah my bad sorry. Is there anything you can do to get those old ones off
@types
?
Yep. I'll continue this conversation over in https://github.com/greensock/GreenSock-JS/issues/231
I've integrated the gsap library with an @angular/cli project using .angular-cli.json as the method shown here
Then, in the TS file
@ViewChild('imageTest') imageTest;
testImage() { let imageTest = this.imageTest.nativeElement; TweenMax.to(imageTest, 1, { width: '50%', repeat: 3, repeatDelay: 0.5 }); }