Intensive JS Processing causes animated GIF to stop animating

Discussion in 'Javascript' started by Chris Moltisanti, Jun 4, 2006.

  1. Hi,

    I am executing a piece of javascript that does some intensive
    processing (sorting large tables). This can take a good few seconds so
    I have an animated gif as a progress bar to let the user know that
    something is happening.
    However, the GIF does not animate when the javascript is processing.
    Anyone know why?
    I am aware that animated GIFs stop animating when a page is loading,
    but I am not loading the page here.

    Hope someone can help,

    Thanks

    Chris
     
    Chris Moltisanti, Jun 4, 2006
    #1
    1. Advertising

  2. Chris Moltisanti

    RobG Guest

    Chris Moltisanti wrote:
    > Hi,
    >
    > I am executing a piece of javascript that does some intensive
    > processing (sorting large tables). This can take a good few seconds so
    > I have an animated gif as a progress bar to let the user know that
    > something is happening.
    > However, the GIF does not animate when the javascript is processing.
    > Anyone know why?


    JavaScript is single threaded, so what normally happens is that browsers
    will not update the display until a script finishes - this is generally
    a good idea. You can get around that by starting your gif, then
    starting the sorting using setTimeout with a very short timeout (say 1ms).

    e.g.

    function startSort(){
    /* start animated gif */
    setTimeout('doSort()',1);
    }

    function doSort(){
    /* sorting code */
    }


    --
    Rob
     
    RobG, Jun 5, 2006
    #2
    1. Advertising

  3. Thanks for the reply.
    I tried this and it doesnt work. If I set the timeout to 1000 ms then
    my GIF is animated for 1 sec but it still stops after that until the JS
    is finshed processing.....

    Chris
     
    Chris Moltisanti, Jun 5, 2006
    #3
  4. Perhaps have another window instance do the sort for you, like a hidden
    iframe.





    "Chris Moltisanti" <> wrote in message
    news:...
    > Thanks for the reply.
    > I tried this and it doesnt work. If I set the timeout to 1000 ms then
    > my GIF is animated for 1 sec but it still stops after that until the JS
    > is finshed processing.....
    >
    > Chris
    >
     
    news.chello.nl, Jun 5, 2006
    #4
  5. Hey,

    I tried this out and it doesnt seem to make a difference. When I call
    the javascript in my iframe e.g. window.myIFrame.doSort();
    this call is the still executed in the same thread as the othe
    javascript. Therefore it will wait for the processing to continue befor
    it updates the GUI.
     
    Chris Moltisanti, Jun 6, 2006
    #5
    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. Jeronimo Bertran

    Creating animated GIF dynamically

    Jeronimo Bertran, Nov 13, 2003, in forum: ASP .Net
    Replies:
    1
    Views:
    515
    Xin Huang [MSFT]
    Nov 14, 2003
  2. Shabam

    Animated GIF handling

    Shabam, Mar 5, 2004, in forum: ASP .Net
    Replies:
    0
    Views:
    370
    Shabam
    Mar 5, 2004
  3. =?Utf-8?B?S29lbiBIb29yZWxiZWtl?=

    reading an animated gif ...

    =?Utf-8?B?S29lbiBIb29yZWxiZWtl?=, Oct 9, 2004, in forum: ASP .Net
    Replies:
    2
    Views:
    540
    =?Utf-8?B?S29lbiBIb29yZWxiZWtl?=
    Oct 10, 2004
  4. sridev
    Replies:
    0
    Views:
    103
    sridev
    Jun 13, 2006
  5. Replies:
    10
    Views:
    191
Loading...

Share This Page