SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Enthusiast
    Join Date
    May 2010
    Posts
    28
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Property appears to be undefined yet causes no error

    In this tutorial:
    http://www.switchonthecode.com/tutor...fade-animation
    The variable FadeTimeLeft is part of an expression assigned to the FadeTimeLeft property of the element object:
    Code:
    element.FadeTimeLeft = TimeToFade - element.FadeTimeLeft;
    Yet I looked through this code and I don't see it defined anywhere so I have no idea what value it holds.
    Thanks for any suggestions.

  2. #2
    SitePoint Enthusiast
    Join Date
    May 2010
    Posts
    28
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Actually first time button is clicked, we assign a value of 1000 to FadeTimeLeft:
    Code:
    element.FadeTimeLeft = TimeToFade;
    Then in the animateFade() function, the first time it is called, we subtract 33 from a 1000 to get 967:
    Code:
    element.FadeTimeLeft -= elapsedTicks;
    Now next time the button is clicked, if coinciding a transition, then we subtract FadeTimeLeft from TimeToFade:
    Code:
    element.FadeTimeLeft = TimeToFade - element.FadeTimeLeft;
    This doesn't make sense to me. We are now subtracting 967 (current value of FadeTimeLeft, if this is second click and occuring during the transition) from 1000 to get 33 and then assigning it to FadeTimeLeft. But if FadeTimeLeft is now 33, then the animatino will be over. Its value should be 967 at this point so we can continue decrementing it by 33.
    I'm obviously missing something here. Thanks for response.

  3. #3
    SitePoint Enthusiast
    Join Date
    May 2010
    Posts
    28
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    If I could delete the two above posts, I would because I think I understood that part, but here:
    Code:

    if(element.FadeState == 1 || element.FadeState == -1)
    {
    element.FadeState = element.FadeState == 1 ? -1 : 1;
    element.FadeTimeLeft = TimeToFade - element.FadeTimeLeft;
    }

    When the transition is reversed, we never call the setTimeOut function here. So how is it supposed to continue fading?


Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •