Jump to content
Search Community

Trying to figure out how to draw button border on hover

rahim 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

Hi there!

 

I've been going at this for a while now, so thought i'd ask for some help. ?

 

I'm trying to create a button where the border around it is drawn on hover. I used an SVG since so I there could be a space there for an arrow. I don't have the DrawSVG plugin, so I coded it with plain javascript. I was able to get the animation to work on hover, however the full border remains there before and after the hover. 

 

Is there a way to make this happen using TweenMax without DrawSVG?

 

Thanks for your help!

See the Pen MWWmYZy by rrspence (@rrspence) on CodePen

Link to comment
Share on other sites

Hi there! 
 

I was able to get the animation to work using the technique above. Thanks for your help with that! 
 

My goal is to have the line to act as a border on a button that runs the animation on hover. However, I’ve only been able to get the animation to run when hovering over the line which is really small, and it ends up animating multiple times anytime the mouse touches that area. 
 

Is there any way to increase the hover area so the animation runs when the mouse touches the whole button?

 

Thanks for your help!

Link to comment
Share on other sites

1 hour ago, rahim said:

My goal is to have the line to act as a border on a button that runs the animation on hover. However, I’ve only been able to get the animation to run when hovering over the line which is really small, and it ends up animating multiple times anytime the mouse touches that area. 
 

Is there any way to increase the hover area so the animation runs when the mouse touches the whole button?

 

Put the mouseenter event on the button itself, not the SVG.

  • Like 1
Link to comment
Share on other sites

Hey guys,

 

I'm still having sooo much trouble with this. I just don't know what i'm doing wrong! 

 

I'm trying to get the effect above to work on all of the buttons in a page. Tried giving the buttons different class names and creating a separate timeline for each, tried giving them all the same class name then selecting all of them and using a .forEach( ). Still can't get anything to work. Can anyone please explain what's going on here??? I know I'm doing something wrong here, I'm having so much trouble with GSAP! 

 

I've included the codepen below. 

 

Thanks for all of your!

 

See the Pen eYYRMme by rrspence (@rrspence) on CodePen

Link to comment
Share on other sites

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