Jump to content
Search Community

Official documentation on using GSAP with CommonJS / ES6

EmpireJones 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

Does GSAP not officially support CommonJS/ES6 at the current time (July 2016)? I've seen various posts on hacks to get this to work, but I was hoping that there is a clean/official way of supporting it at this time.
 
For example, I'm able to import TweenMax via:

import { TweenMax } from 'gsap';

How do I import something like Linear for easing?

 

Thanks!

Link to comment
Share on other sites

Hi and welcome to the GreenSock forums.

 

Unfortunately I haven't used GSAP with CommonJS/ES6, only ES5 through Browserify and NodeJS, but (and please correct me if I'm wrong) as far as I know importing modules in ES6 work in a similar fashion. Also you report that importing the TweenMax class is working for you. Question, are you able to create animations using the constructor?:

TweenMax.to(el, 1, {x:100, y:100});

Finally in order to import the easing functions, they are already present in the TweenMax file. Check the first paragraph in the docs:

 

http://greensock.com/docs/#/HTML5/Animation/TweenMax/

 

Hope this helps.

  • Like 1
Link to comment
Share on other sites

As of 1.19.0, you should be able to do exactly what you were requesting. Any of the classes that are inside TweenMax will get exported by that default file, thus you can do: 

import {TweenMax, Linear, TimelineLite, Elastic} from "gsap";

Again, please make sure you've got 1.19.0. 

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