Jump to content
GreenSock

Search In
  • More options...
Find results that contain...
Find results in...
Sumanjit SenGupta

Animations not working on reload

Recommended Posts

I've started with javascript and GSAP in my project. I've used Tweenlite.to() to change the opacity of some anchor tags.

 

The animations are working absolutely great the first time I'm opening the page. But if I reload the page, the tweens are not working. I'm closing the tab and opening the page in a new tab and its working again.

Why is it so?

 

 

<--HTML file-->

<html>

<head>

<script src="animations.js"></script>
</head>
<body>
...
...
<nav>
                                <a href="#" id="a_home" onMouseOver="inHome()" onMouseOut="outHome()">
                                Home
                                </a>
...
</nav>
...
...
</body>
</html>

 

<--animations.js-->

 

function inHome(){
TweenLite.to("#a_home",0.3,{css:{opacity: 1}});
}
function outHome(){
TweenLite.to("#a_home",1.5,{css:{opacity:0.7}});
}
Link to comment
Share on other sites

Hi and welcome to the GreenSock forums.

 

I wasn't able to replicate the behavior you described. My tests show the animation working fine on reload of the page.

I edited the pen only to make the effects more noticeable (added color and more extreme change in opacity)

 

I tested in Chrome and FireFox

 

http://codepen.io/GreenSock/full/IBsit/

 

If the problem persists please provide more details on how to replicate it.

 

Also please note that it is not necessary to wrap the properties inthe css{} object. The shorter code below will work fine:

function inHome(){
  TweenLite.to("#a_home",0.3, {opacity: 1});
}
function outHome(){
  TweenLite.to("#a_home",1.5, {opacity:0.7});
}
Link to comment
Share on other sites

Hi,

 

This is a very freaky behaviour that sometimes shows it's ugly face. I remember a couple of posts like this, please check the following posts and see if the solutions proposed there solve your issue:

 

http://greensock.com/forums/topic/6901-animated-scroll-to-anchor-tag/?p=25830

 

http://greensock.com/forums/topic/7817-reset-all-animations-when-returned-to-page/?p=29836

 

Rodrigo.

Link to comment
Share on other sites

I just tested

See the Pen IBsit by GreenSock (@GreenSock) on CodePen

and did not see the above described behavior.. the animation worked on every page reload.

 

Tested on PC - Windows 7 (64-bit) Firefox 31 and Chrome 36 (Version 36.0.1985.143 m)

 

:)

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