http://codepen.io/vincentccw/pen/svBte
This is the code I'm using:
///////////////////////////////////////////////////////////////////////////////////////
var hoverEffect = new TimelineMax();
$('div').on('mouseenter', function(){
hoverEffect.to($(this), .2, {top:"-=20px",ease:Quad.easeIn});
}).mouseleave(function(){
hoverEffect.to($(this), .2, {top:"+=20px",ease:Quad.easeOut});
});
///////////////////////////////////////////////////////////////////////////////////////
On first hover, the div straight away jump into the end and skip the animation but when hover the second and third time, it goes back to normal....
I also noticed that when I place my variable inside the mouseenter function it fixes the problem but is there anyway that I can place the variable outside the function?