Jump to content
GreenSock

Search In
  • More options...
Find results that contain...
Find results in...
PointC

DrawSVG starting at 50% 50% with stroke-linecap="round"

Recommended Posts

I have a bunch of paths that need to start and sometimes end at 50% 50%. They also need to have a round linecap. Starting at either 0% 0% or 100% 100% works well of course, but the 50/50 line starts with that circle sitting out there. I've been getting around this by setting the linecap to either 'round' or 'butt' as needed immediately before and/or after tweening, but I wanted to make sure I wasn't missing something easier.

 

See the Pen ePvWLa by PointC (@PointC) on CodePen

 

Happy tweening.

:)

 

  • Like 2
Link to comment
Share on other sites

Have you tried calling SVG technical support?

 

That's just the nature of how strokes are drawn. The way I've dealt with that in the past it to animate the scale or stroke width from 0.

 

See the Pen ZqeJYe by osublake (@osublake) on CodePen

 

 

 

 

 

 

  • Like 4
  • Haha 1
Link to comment
Share on other sites

3 minutes ago, OSUblake said:

Have you tried calling SVG technical support?

 

I am SVG technical support so that would just result in a recursive loop. ?

 

Yeah, I like your idea of animating the stroke width. It looks less jarring than suddenly changing the linecap or the autoAlpha. 

 

Thanks.

:)

  • Like 2
  • Haha 2
Link to comment
Share on other sites

Yeah, exactly. GSAP can do some wizardry at the start/end of the lines (as you saw), but it just isn't feasible right in the middle. I toyed with sensing that condition and shoving the offset way to the start or end, but that causes other problems (like throwing the "from" values off when captured at that moment). In short, @OSUblake's idea is best. 

  • Like 2
Link to comment
Share on other sites

when I was a kid we'd put a gif the same color as the background color on top of it and then move it 10,000px to the right when the animation begins.

  • Like 2
  • Haha 1
Link to comment
Share on other sites

Yeah, I tinkered with a few things like that. I animated a little rectangle at the end of each line to make it look like the round linecap was collapsing into a butt cap, but it ended up being more trouble that it was worth. The animation is pretty quick so I can probably get away with just hiding it too. For a slower animation, Blake's idea works well.  I had a hunch Jack had considered something for this scenario and it probably wasn't feasible, but thought I'd float the question for creative solutions. Who knows, maybe it will help someone else doing battle with SVGs. 

:)

 

  • Like 2
Link to comment
Share on other sites

Yup - that's a good idea too @elegantseagulls. Thanks for jumping in. 

 

Happy tweening.

:)

 

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