Jump to content
Search Community

Timeline Function Called Twice per Loop

nss5161 test
Moderator Tag

Go to solution Solved by GreenSock,

Recommended Posts

Hi Forum!

 

In this pen example, I have created two timelines that are to loop infinitely. One timeline controls the shape morph and opacity of the flame, and the other timeline is to control the eye movement.

 

Focusing on the Issue... In the second timeline (Scene2: The eyes), the "tl2.to" function calls the custom function "getRandomValues(min, max)" that I have created below. When I console log a test value in the function call, I am seeing a duplicate value every call. You can replicate this issue by opening the console log in your browser or in CodePen depending on your preference. I have altered the function and the timeline criteria with no attempt to fix the issue. Can you please assist me with this issue?

 

Please ask questions if I have not explained well! I will reply as soon as possible.

 

tl2.to(".pupil", {
  duration: 0.1,
  ease: "linear",
  x: function(){
    console.log("test");
    return getRandomValue(-2, 2);
  }
});
function getRandomValue(min, max) {
  return (Math.random() * (max - min) + min).toFixed(1);
}

 

See the Pen oNYQZzV?editors=1010 by nss5161 (@nss5161) on CodePen

Link to comment
Share on other sites

5 minutes ago, PointC said:

It's really cool how fast bugs like a double repeatRefresh get fixed around here.

It's really cool how fast bugs like a double repeatRefresh get fixed around here.

 

I'd fix that for you, but then nobody would have the chance to get a laugh at that 😅

  • Like 1
  • Haha 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...