Jump to content
GreenSock

Search In
  • More options...
Find results that contain...
Find results in...
Mazlum Tanrıkulu

Gsap and Angular 9: Unexpected token 'export'

Recommended Posts

Hello everyone
I'm getting an error from gsap-core.js when i try to use gsap with angular 9. I have used gsap with angular 7 but now I am using angular 9 and getting this error: Screenshot_1.png.2660c6c4b488873cfbd291f0831d20ec.png
detail:
Screenshot_2.png.9dadda1ac385455902f99c2568195242.png

angular.json:
Screenshot_3.png.98b4a24640932e7ab94c187161cbaa54.png

js files and directories:
Screenshot_4.png.8c97129b1b640bc328e4dbdb03a557a0.png
app.component.js:
Screenshot_7.png.e31f5f8a9acc5afa570736418246e75d.png
menu.component.js:
Screenshot_5.png.430deea645304bca95dbdbdf94a3e13a.png
and using:
Screenshot_6.png.d9fdb1ee99e77ef3f03d3da684f4fdad.png

what is the problem I didn't understand. How can i solve this problem. please help me.
thnx a lot

Share this post


Link to post
Share on other sites

I try to change the path of gsap to 

"node_modules/gsap/dist/gsap.min.js"

in angular.json and it is working I suppose

Share this post


Link to post
Share on other sites
6 minutes ago, Mazlum Tanrıkulu said:

I try to change the path of gsap to 


"node_modules/gsap/dist/gsap.min.js"

in angular.json and it is working I suppose

 

You're importing gsap twice. Either use the import syntax in every file that uses gsap, or add the script to your angular.json file, but not both.

 

When using the import syntax, you only need to import gsap though. There is no need to import TweenLite/Max, TimelineLite/Max, or any of the eases.

import { gsap } from "gsap";

https://greensock.com/docs/v3/Installation

 

Eases can be done with strings.

gsap.to(element, { duration: 2.5, ease: "bounce.out", y: -500 });

https://greensock.com/docs/v3/Eases

 

And you most certainly don't need jQuery.

import { gsap } from "gsap";

gsap.fromTo(".mobile-screen", {
  marginLeft: "20vw"
}, {
  duration: 0.3,
  marginLeft: "100vw"
});

 

👆 animating margins is slow. It would be much better to animate x.  And with angular, you really should be using refs instead selector strings.

https://www.techiediaries.com/angular-elementref/

 

  • Like 5

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...

  • Recently Browsing   0 members

    No registered users viewing this page.

×