GSAP 2.0 Released

May 23rd 2018 | Carl
favorite

15849

We've been getting requests for better support of modern build tools. With version 2.0 we're pleased to announce a switch to ES modules via NPM which should make your building, bundling, and tree shaking even smoother. Don't worry, the UMD/CommonJS flavor is still available and the CDN serves the same browser-friendly files as always.

If terms like "UMD", "ES Modules", and "tree shaking" leave you scratching your head, fear not - GSAP 2.0 will work like a champ for you (as usual). There are no syntax, API, or browser-support changes. None. The major version bump was primarily due to the switch to ES modules for NPM users, that's all.

DOWNLOAD GSAP NOW

NPM, ES Modules, Webpack, oh my!

Modern bundlers like Webpack and Rollup just love to snack on ES modules these days, usually grabbing them from NPM. So GSAP 2.0 is extra delicious covered in its chocolatey ES module outer shell.

(If you're not using a bundler or NPM, skip this section entirely)

npm install gsap

Then you can import individual classes like:

import TweenMax from "gsap/TweenMax";
import Draggable from "gsap/Draggable"; 

TweenMax includes (and exports) many of the commonly-used classes so you can also do this:

import { TweenMax, TimelineLite, Power2, Elastic, CSSPlugin } from "gsap/TweenMax";

(TweenMax includes TweenLite, TimelineLite, TimelineMax, CSSPlugin, RoundPropsPlugin, BezierPlugin, DirectionalRotationPlugin, AttrPlugin, and all eases except CustomEase, CustomWiggle, and CustomBounce)

As a convenience, there's also an "all" file that imports/exports every GSAP tool (except members-only bonus plugins), so you can do this:

import { TimelineMax, CSSPlugin, ScrollToPlugin, Draggable } from "gsap/all"; 

IMPORTANT: if your animations aren't working as expected, it's likely an issue with tree shaking which can be easily resolved by referencing any plugins you're using. Read more.

UMD/CommonJS

If your environment doesn't accommodate ES modules yet, don't worry - we've got you covered. There's a "umd" directory that contains...you guessed it...regular old ES5 UMD (Universal Module Definition) versions of the files which are compatible with pretty much everything (RequireJS, Browserify, etc.). So you could import them like:

//get the UMD versions. Notice the "/umd/" in the path...
import { TweenMax, Power2, TimelineLite } from "gsap/umd/TweenMax"; 
import ScrollToPlugin from "gsap/umd/ScrollToPlugin"; 
import Draggable from "gsap/umd/Draggable";

What about bonus plugins like MorphSVGPlugin?

Obviously we can't distribute the members-only bonus plugins via NPM, so all you need to do is log into your GreenSock account and download the latest zip which has a "bonus-files-for-npm-users" folder with the bonus plugins. Then just plop that into your project, like maybe in your /src/ folder (or wherever) and import them directly. For example, to save some typing you could rename the "bonus-files-for-npm-users" to simply "gsap-bonus" and put that in the root of your project and then:

import MorphSVGPlugin from "./gsap-bonus/MorphSVGPlugin";
import SplitText from "./gsap-bonus/SplitText";

You could certainly put the bonus files in /node_modules/gsap/ if you prefer, but most people don't like doing that because it makes things less portable/updatable.

There's a brand new page in the docs dedicated to NPM usage.

NEW: Custom rounding increments in RoundPropsPlugin

Have you ever needed to round animated values to the nearest 10 or hundredth? With the new object syntax in RoundPropsPlugin, you can round properties to various custom increments, not just integers! Simply pass in [property]:[increment] pairs like so:

TweenLite.to(element, 5, { x:600, y:100
  roundProps:{
    x:10, //round x to nearest increment of 10
    y:0.1 //round y to nearest increment of 0.1
  }
});

Watch the video

Demo

See the Pen RoundPropsPlugin Update by GreenSock (@GreenSock) on CodePen.

NEW: SplitText "specialChars"

SplitText recognizes a new specialChars property that allows you to specify an array of special characters to protect. This is typically used for multi-character symbols like in some languages where there are pairs (or sometimes even 4 characters) combined to form a single character.

See the Pen SplitText with specialChars feature by GreenSock (@GreenSock) on CodePen.

No need to do this for most emoji's, though, because those are already supported natively in SplitText!

Got questions?

If you haven't checked out the forums, you're missing out! It's a great place to get your questions answered and participate in the community. We carefully monitor and answer questions there. Or feel free to contact us directly if you prefer.

Changelog

View the full changelog here (note: version 2.0.0 is just 1.20.5 with a version bump to avoid breaking changes for NPM users)

Happy tweening!

DOWNLOAD GSAP NOW


Get GSAP

Version: 2.0.2 updated 2018-08-27

Core

    Extras

      Plugins

        By using GreenSock code, you agree to the terms of use.

        For an all-access pass to premium content

        Join Club GreenSock