Jump to content
Search Community

Having Trouble With Button Hover Animation

jemfrim949 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,

 

I thought I made progress with a previous post on button hover 3d animation- guess not. It was explained very well but for some reason I am not able to translate it to other GASP box shadow styles.

http://forums.greensock.com/topic/9355-how-to-animate-buttons-on-hover-with-gsap/

 

I am trying to work my way up through the different 3d box shadow properties located here: http://www.greensock.com/css3/ this time I am working on the orange blur box shadow.

 

Here is my code: 

See the Pen bkBLa by anon (@anon) on CodePen

 

My end goal is to have these box shadow properties to run when user hovers on any buttons on my site.

Link to comment
Share on other sites

Hello jemfrim949, and Welcome to the GreenSock Forums!

 

Here is a fork of your example working:

See the Pen BpoLi by jonathan (@jonathan) on CodePen

 

You were missing some squiggly brackets, ending parenthesis, and some variables were not defined as variables:

var load3 = function () {
  
    var duration = 0.2,
        button = document.getElementById("button");

    button.onmouseenter = function(){     
    	TweenMax.to(button, .3, {
           boxShadow: "0px 0px 10px 4px #f60",
           backgroundColor:"#f60",
           borderColor:"#f60"
        });
    };

    button.onmouseleave = function(){
         TweenMax.to(button, duration, {
           boxShadow: "0px 0px 0px 0px",
           backgroundColor:"green",
           borderColor:"none"
         });
    };
  
};

if (window.addEventListener) {
  window.addEventListener('load', load3);
} else if (window.attachEvent)  {
  window.attachEvent('load', load3);
}

Also here is different example that shows a simple hover in and out (mouseeneter and mouseleave) using jQuery for cross browser event binding:

 

See the Pen tukhf by jonathan (@jonathan) on CodePen

 

Hope that helps? :)

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