Jump to content
Search Community

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

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

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

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

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