Jump to content
Search Community

Vue js and drawSVG

JACK LEE 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

I am not sure what's the problem that causes the drawSVG not being called.

I have also tired the splittext plugin and that works fine.

Firstly, The TimelineMax is working, the last piece of code in red is working fine but not others with the "drawSVG"  in it.

 

animateLine: function () {
      var svgs = document.getElementsByTagName('svg')
      var tl = new TimelineMax()
      tl.staggerFromTo(svgs, 1, {drawSVG: '100%'}, {drawSVG: '50% 50%'}, 0.1)
        .fromTo(svgs, 0.1, {drawSVG: '0%'}, {drawSVG: '10%', immediateRender: false}, '+=0.1')
        .staggerTo(svgs, 1, {drawSVG: '90% 100%'}, 0.5)
        .to(svgs, 1, {rotation: 360, scale: 0.5, drawSVG: '100%', stroke: 'white', strokeWidth: 6, transformOrigin: '50% 50%'})
        .staggerTo(svgs, 0.5, {stroke: 'red', scale: 1.5, opacity: 0}, 0.2)
    }

Screen Shot 2017-08-08 at 10.21.09.png

Link to comment
Share on other sites

Hi and welcome to the GreenSock forums,

It looks like you are passing a whole <SVG> as the target of the DrawSVG tween. 

You need to select a path, polyline, rect, circle or some element(s) with a stroke on it.

Check out the docs for a video and demos: https://greensock.com/docs/Plugins/DrawSVGPlugin

More demos here: https://codepen.io/collection/DYmKKD/

 

If you need more help let us know. 

  • Like 2
Link to comment
Share on other sites

thanks for the reply, I've tried to select a path as shown in the below, but still not working. 

maybe it's something wrong with the way I import drawSVG? can you please check the way i importing the drawSVGplugins, i've done the same for split text plugin and it works fine.

 

598ac5a665a88_ScreenShot2017-08-09at16_19_39.png.c2f1e288d62d43936208825563ff06e5.png

598ac56948ec5_ScreenShot2017-08-09at16_18_17.png.37a1e9405ce549920d2b93db4bee70a8.png598ac565c5309_ScreenShot2017-08-09at16_18_04.png.8ac2ac87a9df875e84ebfe0a8f4ea4a3.png

598ac64e0478d_ScreenShot2017-08-09at16_22_24.png.56165078be74691378763f64bb5e6824.png

Link to comment
Share on other sites

This is fine...

import 'gsap/DrawSVGPlugin'

 

But there was nothing wrong this.

import DrawSVGPlugin from 'gsap/DrawSVGPlugin'

 

You were just using it incorrectly. You should not do this. All you need to do is import the file, and it will automatically be registered as a plugin.

// DON'T DO THIS
var drawSVG = new DrawSVGPlugin();

 

The only reason you would ever need to reference the plugin directly is to access some static methods, like here.

 

 

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