setTimeOut vs time-based animation

Discussion in 'Javascript' started by Brainless, Oct 19, 2003.

  1. Brainless

    Brainless Guest

    hi...

    I've recently created a dhtml thing on http://www.shapers.nl/ that
    animates a lot of images. The thing I want to solve is the lag that
    occurs when a new animation is initiated.

    To make it time-based I calculate the entire animation on beforehand
    and create numerous setTimeOuts in a repeat loop (it's the loop that
    creates the lag).
    Creating an animation like this has some more disadvantages:
    - it's 'difficult' to suddenly end the animation (you'd have to kill
    all remaining setTimeOuts)
    - setTimeOut is an inaccurate way of animating: the position of an
    image might be changed twice per cycle or (the other way around) a
    position could change once per two cycles

    I need to code something that calculates the position of an image
    every cycle. To do this I need the deltaT (= milliseconds between
    cycles), and for that I need some sort of event (or workaround) that
    occurs every cycle (and works both in IE and Mozilla).

    I've tried calculating deltaT with a setTimeOut('getDeltaT()',1) and
    with the mouseMove event but both seem slightly inaccurate since they
    sometimes return deltaT=0.

    anybody got a solution?

    grtz...

    Ron
    Brainless, Oct 19, 2003
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Enigma Curry
    Replies:
    1
    Views:
    339
    Enigma Curry
    Apr 9, 2006
  2. flamesrock
    Replies:
    8
    Views:
    439
    Hendrik van Rooyen
    Nov 24, 2006
  3. dch3
    Replies:
    2
    Views:
    508
  4. Jorch
    Replies:
    5
    Views:
    132
  5. Replies:
    18
    Views:
    187
    Randy Webb
    Sep 21, 2006
Loading...

Share This Page