Jump to content
Search Community

TextPlugin not working with import

mkurdziel

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

Posted

Hi!

 

I have a problem with TextPlugin.

I use Webpack with Gulp, and im importing it this way: 

import { TweenMax, TimelineMax, TextPlugin } from 'gsap';

TweenMax and TimeLineMax are working fine but TextPlugin is not working at all. Just nothing happen.

 

Here is my code:

var tlHome = new TimelineMax({});

tlHome.to( ".heading--intro__1", 2, {text: "Design your brand's story."})
      .to( ".heading--intro__2", 2, {text: "Scale it up globally."})
      .to( ".heading--intro__3", 2, {text: "Predict the future."})

 

Any ideas why is TextPlugin not working?

Posted

Hey mkurdziel,

 

I'm not super experienced with Webpack myself but I wonder if you have gone over the guide in the Docs, specifically the bit that talks about "Tree shaking"?

 

It is possible that when you're bundling up Webpack is throwing it away thinking it is not being used.

  • Like 5
Posted

Thanks Dipscom! It was exactly what i was looking for! It's woking :)

  • Like 1
Posted

Glad to hear it's working, but I'm a tad confused because "gsap" actually points to TweenMax (long story), so the only things exported from there are tools that are inside TweenMax (like CSSPlugin, TweenLite, TweenMax, TimelineLite, TimelineMax, all the eases, etc.) but TextPlugin is NOT included in TweenMax. So you can either import things from "gsap/all" or you can import TextPlugin directly (and separately) like:

 

import TextPlugin from "gsap/TextPlugin";

 

  • Like 2
Posted

I also thought that "gsap" points to gsap folder...

I made it this way:

 

import { TweenMax, TimelineMax, TextPlugin } from 'gsap/all';

// Webpack treeshaking fix
const plugins = [ TextPlugin ];

 

Looks like a Webpack uses unnecessary feature in this case.

Maybe there is some solution.

Posted

It's working fine for you, right? Or were you saying that something else broke? Do you still need a solution? 

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