Jump to content
Search Community

How to use GSAP in the typescript project of layabox ?

NaughtyDog test
Moderator Tag

Recommended Posts

Hey NaughtyDog. Welcome to the GreenSock forums!

 

Can you please provide a basic demo of GSAP not working with layabox? Maybe using something like CodeSandbox or StackBlitz? 

 

If all you need are the Typescript declarations for GSAP 3, you can get those by downloading the ZIP file from the GreenSock website. Do note that we're still working on the Typescript declarations.

Link to comment
Share on other sites

  • 2 weeks later...

I imported the class library under the umd folder in gsap-member.zip into the TypeScript project in Layabox, compiled it and ran it successfully.

But if I import the class libraries in the esm folder into the TypeScript project, or if I import the class libraries in the src folder into the TypeScript project, Either of these two ways, the following error occurs after compiling the run.

q12.thumb.png.98f9b5e658df2dcfe65e42d6df6c7f50.png

Link to comment
Share on other sites

It looks like your build system isn't set up to understand ES modules, that's all. It's unrelated to GSAP. If the UMD files work, you're welcome to just use those. They're exactly the same thing, just formatted differently for situations exactly like this.  Is there some reason you don't want to use the UMD files?

  • Like 1
Link to comment
Share on other sites

I'm just trying to figure out what the problem is, and how to go about fixing it.
I got the following response from the official Layabox.
The engine is ES6 enabled and automatically handles the import and export of src code at compile time.
However, there have been issues with the browser's support for imports and exports, so we don't recommend developers use it outside of the user folder (i.e. SRC).
For browser support, see MDN.
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/export
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/import

I loaded the GSAP class library in the index.js file and then embedded index.js in the index.html file. in the MDN instructions, it explicitly says that the export statement cannot be used in the embed script.

q17.thumb.png.dfb453d4094f0feec4b9abca91fa11d4.png
 

I'm trying other methods that will allow me to successfully reference the GSAP class library in the SRC folder. Do you have any good ideas?
Please forgive my stubbornness, and in any case, thank you for taking the time out of your busy schedule to respond to me. Thank you!

Link to comment
Share on other sites

9 hours ago, NaughtyDog said:

However, there have been issues with the browser's support for imports and exports, so we don't recommend developers use it outside of the user folder (i.e. SRC).

 

The way that sounds is that you can only use modules for files inside the src folder. For modules, you need to install it just like on the docs.

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

 

And then import gsap in every file you use it.

import { gsap } from "gsap";

 

 

  • Like 1
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...