Jump to content
Search Community

create-react-app registerPlugin drawSVG

trtg2xv test
Moderator Tag

Go to solution Solved by GreenSock,

Recommended Posts

hi,i using gsap3 in create-react-app  But ,I hava some problems;  
I don't know why ' drawSvg ' not working;
I   'import  DrawSVGPlugin  from "gsap/all"  and register it,but console has warning
image.png.33b1cf5be77ce34b6c300100a95a202c.png
import  DrawSVGPlugin  from "gsap/all";
  useEffect(() => {
    gsap.registerPlugin(DrawSVGPlugin);
    console.log("drawSVG");
    let t1 = gsap.context(() => {
      gsap.from('#Line1',{
        drawSVG:"0%",
        duration:3
      }
      )
    });
    return () => t1.revert();
  }, []);
Link to comment
Share on other sites

Hi there! Draw SVG is a paid benefit of Club GreenSock membership, I don't see that associated with your account so that may be the first hurdle.

The other issue is how you're importing DrawSVG - this is correct
 

import { DrawSVGPlugin } from "gsap/DrawSVGPlugin";


You can see more about installation here -> https://greensock.com/docs/v3/Installation?checked=core,drawSVG#modules

We have a starter template here too, it uses React and our gsap-trial package. 💚 By using the trial package you can use the club plugins for free on stackblitz, codepen and codesandbox

https://stackblitz.com/edit/react-iqmjfx?file=src%2FApp.js


We also have a React guide here.
 


Hope these links help and good luck with your project!

  • Like 1
Link to comment
Share on other sites

  • Solution
1 hour ago, trtg2xv said:

Thank you for your reply, this reply is very helpful, is there a free version of the plugin for drawing SVG animation?

No, but you could animate the CSS strokeDashoffset property. It’s not nearly as easy or compatible, but in many cases it works. DrawSVGPlugin solves a lot of cross-browser issues and greatly simplifies things. So if you want to avoid getting the proper Club GreenSock membership, you could go the manual route but please don’t expect us to walk you through all that. Keep in mind that the only way we can do what we do is because of Club GreenSock and our supporters there. Bonus plugins like DrawSVG are our way of saying “thanks” to those who support our efforts. 

 

Good luck to you!

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