Jump to content

Codepen Notification

You didn't provide a codepen sample that illustrates the problem. It really helps us quickly identify problems. This isn't mandatory, but it will get you better/faster results. Would you like to add one?

PointC

Member Since 18 Jun 2013
Offline Last Active Today, 02:13 AM
*****

Topics I've Started

Animating SVG circle strokes from the 12 o'clock position with DrawSVG

Yesterday, 06:32 PM

Hey fellow GreenSockers. I was going to post this in the SVG Gotchas thread, but this question is asked a lot around here so I thought maybe a new topic would be the way to go.

 

SVG circles start at 3 o’clock and most people want to animate the stroke from the 12 o’clock position. Conventional wisdom would tell you to simply rotate the circle by -90 degrees and you’re all set, but there are some problems with this approach.

 

Using GSAP to rotate the circle -90 degrees will work perfectly fine in Chrome and FF, but Safari will ignore that set() for some reason. (IE and Edge honor the rotation, but they have another problem.)

 

You can simply add a transform attribute directly to the circle like

<circle cx="500" cy="75" r="60" transform="rotate(-90 500 75)"/>

This will work correctly in Chrome, FF and Safari, but not completely in IE and Edge.

 

If you're animating the stroke with DrawSVG, IE and Edge need the stroke-dasharray set to 0 in the attributes or they will cause problems. If you don’t add that attribute, a regular circle will start at 9 o’clock and the circle that you’ve rotated -90 degrees with GSAP or a transform attribute will start at 6 o’clock. Strangely, if you resize the browser window to the point of the SVG changing size, IE and Edge will correct themselves. 

 

The only bulletproof way I see to draw a circle stroke from the 12 o’clock position with DrawSVG in all browsers is transforming the circle -90 degrees and adding the extra attributes to keep IE and Edge happy.

<circle cx="500" cy="225" r="60" stroke-dashoffset="0" stroke-dasharray="0" transform="rotate(-90 500 225)"/>

It appears that only adding the stroke-dasharray attribute fixes the IE/Edge issues, but I also add a stroke-dashoffset="0" attribute also just to be safe.

 

Check out the demo in all your browsers.

 

Hopefully this helps somebody with this type of animation.

 

Happy tweening.

:)


stroke-linecap and drawSVG issue in IE11 and Edge

30 March 2017 - 02:28 PM

I hit a strange DrawSVG issue on my latest project. I was hunting every line of JS thinking I was doing something wrong, but I finally narrowed it down to the SVG stroke-linecap.
 
If I set the stroke-linecap to 'round' or 'square', IE11 and Edge won't display the stroke as it animates. DrawSVG is animating all the values, but those two browsers display nothing. The weird thing is if I animate a new value for the strokeWidth along with the drawSVG animation, it works perfectly. Even a 1/1,000th change makes it work. Any strokeWidth value works as long as it isn't the same as the original value in the SVG. Another oddity is setting the stroke-linecap to 'butt', 'inherit' or leaving it out causes no problems either. 
 
All is fine in Chrome and FF, but the Microsoft browsers are behaving like fussy children.

Whoo-hoo! I've made it to 1,000 posts. Thanks everyone.

27 February 2017 - 07:37 PM

Hello GreenSock community,
 
This is my 1,000th post here on the forum so I thought I’d say thank you to all of you. You’re such a fantastic group of friendly, creative people. Your code, questions and demos inspire me every day. I learn just as much by answering questions as I do by asking them so the first thousand has been a wonderful education for me. Thank you all for your participation here in GreenSockLand.
 
Special thanks to Jack and Carl for letting me hang out and talk through 1,000 posts. You guys rock!
 
To commemorate the occasion, I made a new little demo. I’ve been having so much fun lately with CustomEase, CustomBounce and CustomWiggle that I thought they should be the focus of the 1,000 post commemorative demo.
 
Commemorative 1,000 Post Demo:
 
Speaking of the new CustomWiggle feature - (shameless self-promotion) – if anyone missed my Wiggle World demo, be sure to check it out. It allows you to interactively play with some of the new wiggle settings.
 
Wiggle World:
 
Thanks again everyone for my first 1,000 posts. I’m looking forward to another thousand. You’re an awesome community. As always, happy tweening to all.
 
- Craig
 
PS If there are any forum lurkers out there who are a little nervous about jumping in, please give it a shot. The GreenSock neighborhood houses a truly special group of people on the web.
 
PicZBbw.jpg
 

One year of GreenSock forum participation – what I’ve experienced

21 June 2016 - 06:11 PM

A GSAP tale:

One goofy guy’s odyssey from knowing nothing to knowing just enough to confuse himself.

(This is crazy long so feel free to jump to the epic conclusion).

 

Greetings fellow GreenSockers. The end of this week marks the one-year anniversary of my first post on the forum so I thought I’d take the opportunity to share my 12-month story and hopefully encourage others to jump into the conversations around here. Maybe you’ll recognize yourself in some of the things I’ve experienced.

 

My quick history in a nutshell

Web design and coding is a second career for me. After 15 years of owning and operating a photography studio and processing lab (back in the film days - yup - I’m old), the digital camera came along and changed that industry, which necessitated a new career for me.

 

I shifted to video production, which led to motion graphics and finally to web design. Our little agency now offers all those services. The web design clients never needed anything fancy so JavaScript took a back seat to HTML & CSS only sites for a number of years.

 

JavaScript & GSAP: false starts and other obligations

I first discovered GSAP a few years ago, but only tried it briefly. It looked cool, but with the time obligations of field video work and motion graphics jobs, it wasn’t something I could work into the schedule.

 

Besides that, it was JavaScript – too complicated I thought. I knew JavaScript was the third piece of a good web designer’s skillset along with HTML and CSS, but I always convinced myself that I didn’t have the time and the sites we built didn’t need it.

 

JavaScript Books + Classes = Fail

I did make a few attempts at reading some JavaScript books and working through some online tutorials, but it just never ‘stuck’. Maybe the examples were too theoretical and dry or they were the wrong books and classes. I really don’t know, but I abandoned the learning process a number of times.

 

Cut and Paste mentality

Why did I really need to learn anyway? You can just Google what you need, cut and paste some code and presto – you’ve got some working JavaScript or jQuery. I only understood a small portion of what I was cutting and pasting, but hey… it worked so the problem was solved. 

 

That’s how I operated for quite some time.  What’s a loop? What’s an array? What’s an object? Who cares?

 

Wait a minute. This is ridiculous.

Last spring, I was remodeling our company website and I had all these grand visions about making things move and behave in certain ways. Googling for code just wasn’t cutting it. I suddenly felt stupid. “This is ridiculous!” I thought. I should be able to learn how to write my own code.

 

Oh yeah, I remembered that GreenSock thing I had looked at a few times and abandoned. That might work. Maybe I could actually learn how to use it this time. 

 

I become a forum lurker

I started lurking in the shadows of the forum. After reading a lot of posts, I saw people asking many types of questions from simple to crazy complicated (at least to me).

 

Two things I noticed were that every effort was made to find an answer (no matter the difficulty level of the question) and not one post was condescending or snarky. That’s quite rare on the ol’ interwebs, isn’t it? Hmmmm…maybe I’m in the right place.

  

Oh boy… time to ask a question of my own

One of the great things about learning GSAP is you’ll also pick up a lot of other JavaScript and/or jQuery along the way. I kept reading and practicing with some simple tweens, but now I had a question. Dare I post? 

 

I suppose, like many others, I feared looking like an idiot even though the forum members and moderators seemed quite nice and helpful. I do several dumb things every day so you’d think I’d be used to it by now. Oh well, here goes. My first question had to do with the indexOf() a Draggable snap array.

 

Within 30 minutes, Diaco and Rodrigo had posted great answers and neither one called me stupid! Yay – how cool.

 

I get hooked on GSAP and the forum

About that same time, I decided our company should discontinue on-site video production and switch to studio only filming. I got tired of lugging loads of video gear in and out of buildings – it’s quite tiring and as I mentioned earlier – I’m old.

 

This freed up some time and I decided to dedicate that time to learning GSAP and maybe, one day, even helping others. It wasn’t too long and I actually knew the answer to a forum question. I posted some information and wow – a little red indicator lit up on my control panel. Someone liked something I wrote. How fun – I’m hooked.  

 

Carl makes direct contact

I continued to learn and experiment. I posted a few additional questions of my own, but I tried to answer more than I asked. If someone posted a question for which I had no answer, I tried to look it up in the docs and figure it out. Most of the time I was far too slow and Jack, Carl or one of the mods would already have the answer posted before I was done reading the question, but it was an interesting way to learn.

 

I did sneak in a few good answers, which led to a private message from Carl. He thanked me for participating and helping in the forums. I thought it was pretty cool that a super smart guy like Professor Schooff would take the time to do that for little ol’ me. My decision to dedicate time to the platform and forum was reinforced.

 

hdaB73Y.jpg

 

Blake and I have a conversation

I don’t recall if it was a back and forth in a forum post or a private message conversation, but Blake told me something that, of course is obvious, but it stuck with me and is important for all of us to remember. He mentioned that we all enter this learning process knowing nothing.

 

If someone of Blake’s considerable skill level can be humble enough to remember first starting out in code, there may be hope for me after all. I guess if you think about it, there was a time when the simple concept of a variable was brand new to all of us. We’re not born with these abilities. They’re learned and we’re all at different points on the educational path. Never feel stupid for not knowing something.

 

Moderator Promotion

Throughout the last year, I’ve continued to learn and study both GSAP and JavaScript. Some of those books I abandoned in the past even make sense now. I’ve tried to be active in the GS community and answer as many forum questions as possible. If I’ve answered a question of yours, I hope you found it somewhat helpful.

 

I’ve cranked out some fun CodePens and finally started a Twitter account to tweet them out. I am nowhere near an expert with GSAP or JavaScript, but I know so much more than I knew a year ago. Apparently I know enough to be entrusted with a forum promotion to Moderator status. I’m honored to be included on such an amazing team. 

 

12 months down – what’s next?

My agency duties are still numerous so I can’t dedicate full time to coding, but it remains something to which I’m committed and thoroughly enjoy. I started this 12-month GSAP journey just wanting the ability to write my own code rather than cutting and pasting the work of others.

 

I’m confident I have achieved that, but I still have days when a simple piece of code just won’t coalesce in my brain and that can be frustrating. I guess we all have those days, right? I make several mistakes every day, but that’s o.k. too. I learn a lot more from my screw-ups than I ever do when it all goes right on the first try.  I plan to keep learning and getting better and when I get stuck, I’ll be able to get an answer from this amazing community.

 

I’ll continue to give back to the GS community by answering any questions that are within my abilities to do so. 

 

The super mods: Jonathan, Blake, Diaco and Rodrigo

Thank you to my fellow moderators. You guys rock and have taught me so much.

 

@Jonathan – if there is a browser bug, quirk or special fix that you are not aware of, I’ve yet to read about it. Your knowledge has helped me fix many pieces of code before they even became a problem. Plus, if I ever have a question of top/left vs. x/y, I know who I’ll ask.   ;)

 

@Blake – if I could be half as good at coding as you, I’d be a very happy guy. Your work always teaches and inspires me. I don’t think you’re allowed to ever stop posting on the forum or we may all show up on your doorstep and ask questions.  :-P

 

@Diaco – your code is always so concise. I deconstruct some of your pens and am astounded by how much you squeeze out of a few lines. If I made some of your pens from scratch, I’d have 20 variables, 5 loops, 12 tweens and 80 lines of code. You do the same with two variables and 4 lines of code. Amazing stuff.  :cool:

 

@Rodrigo – when searching the forum, I often land on one of your past posts and learn a lot. Your knowledge is vast and I wish you had more time to post around here. Your ninja skills are incredibly strong.  :ph34r:  

 

Our superhero leaders

 

@Carl – I’ve participated in several online forums ranging from graphic design to 3D to video production, but the GreenSock forum is the best and a big part of that is you. You not only provide great answers, but you do it in clever ways with just the right amount of humor thrown in here and there.

 

The collection of videos you’ve made is invaluable and should be mandatory viewing for anyone interested in GSAP. I’ve seen you monitoring the forums at all hours of the day and even on weekends. When you get any sleep I’ll never know, but I thank you for your dedication and sharing your knowledge.

 

@Jack – how you had the vision to start GreenSock and write the first version of the animation platform I can only imagine. I’m glad you did because GSAP is such an amazing collection of tools. The friendliness of the community is definitely following your lead. I don’t understand a lot of what you talk about sometimes, but I know enough to be amazed by your brilliance and talent.

 

You call yourself just a guy who geeks out about code, but you’re more than that. You’re a smart and generous innovator who’s created a special brand and place on the web. I think I can safely speak for the community when I say we all appreciate the time and effort you put into helping us make beautiful and high-performance animations. Thank you sir.

 

The epic conclusion. Well… maybe just a regular conclusion.

If you didn’t read the whole post, I don’t blame you. It’s ridiculously long and I’m just some guy you don’t know so I’ll wrap it up with this bit of advice.

 

Whether you’re a genius or feel like an idiot, it doesn’t matter. Try to learn one new thing each day and before you know it, a year will have passed and all those little bits will add up to new skills and abilities. If you’ve never posted on the forum, please jump in and participate. The more voices we have around here, the more we all benefit. If you need an answer, please don’t be afraid to ask a question.

 

Believe me, I’m just some goofy guy in front of a computer. If I can learn this stuff, so can you.

 

As I begin my second year in GreenSockLand, I’m looking forward to learning more, seeing everyone’s work and answering as many of your questions as I can. This is an amazing community and I encourage anyone reading this to set up an account and get involved. My best to all of my fellow GreenSockers. See you around the forums.  :)

 

- Craig (PointC)

 

PS I made a little CodePen to commemorate my one-year forum anniversary. It’s how I felt before and after discovering the power of GSAP. Enjoy.