Jump to content
Search Community

How do I use TimeLineMax in Angular5+ and Typescript

Optiq test
Moderator Tag

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

I'm trying to get TimeLineMax to work in my Angular 5 project and can't figure out what's not being done.  I originally installed the npm package available on the gethub page and found this article https://teropa.info/blog/2016/12/12/graphics-in-angular-2.html#greensock showing how to use it in the OnInit lifecycle and this stackoverflow post https://stackoverflow.com/questions/37135894/using-tweenmax-in-angular2-project which touches on the issue of gtting it up and working.  So far I imported it into my component like this

 

import { TimeLineMax }      from 'gsap';

 

and just to try it out I have this in my component class.

ngOnInit(){
  this.layerAnimation();
}
    
layerAnimation(){
  let anime: TimeLineMax = new TimeLineMax();
  
  anime.from('.redLayer2', 1, {x: -200, opacity: 0});
  
  return anime;
}

 

Nothing is happening.  I've tried adding it to the main.ts file as originally shown in the article, I tried using the @ViewChild method, switched from using that to an ID to a Class, nothing works. I don't know what else to do and really can't find much info on using this with Angular and Typescript.  Can anyone help shed light on this?

 

UPDATE

 

I created a demo on StackBlitz after fixing the typos with no success and ironically the demo works.  I tried re-installing gsap and the animation still isn't working.

 

https://stackblitz.com/edit/gsap-demo?file=app/app.component.ts

See the Pen app.component.ts by edit (@edit) on CodePen

Link to comment
Share on other sites

You have typo, it should be TimelineMax. Also, are you just including TimelineMax? You will need TweenLite and CSSPlugin to make it work. You can include TweenMax instead that includes both CSSPlugin and TimelineMax and few other common plugins.

  • Like 4
  • Thanks 1
Link to comment
Share on other sites

Seeing that I got a working demo now would it be more appropriate to open another topic concerning getting the npm package properly installed on my system or could you guys help with that here?

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