jquery - Continuous Progress Bar in Javascript - Stack Overflow

I am trying to find the best option to create a simple progress bar that I need to be triggered periodi

I am trying to find the best option to create a simple progress bar that I need to be triggered periodically from within another JavaScript script.

Every few minutes, a timer would cause the progress bar to start going from 0 to 100%. Once it reaches 100%, the bar would reset to 0.

I am trying to implement a smooth animated version of the bar, like this one: /. (I tried adapting this particular one but I could not get it to work the way I described)

I am looking into the jQuery UI ProgressBar: Is it possible to use it in the manner I have described?

Thank you.

I am trying to find the best option to create a simple progress bar that I need to be triggered periodically from within another JavaScript script.

Every few minutes, a timer would cause the progress bar to start going from 0 to 100%. Once it reaches 100%, the bar would reset to 0.

I am trying to implement a smooth animated version of the bar, like this one: http://www.webappers./progressBar/. (I tried adapting this particular one but I could not get it to work the way I described)

I am looking into the jQuery UI ProgressBar: Is it possible to use it in the manner I have described?

Thank you.

Share edited Mar 23, 2010 at 3:13 Jon Limjap 95.6k15 gold badges103 silver badges153 bronze badges asked Mar 23, 2010 at 3:09 GoroGoro 10.2k23 gold badges80 silver badges108 bronze badges
Add a ment  | 

1 Answer 1

Reset to default 6

This is pretty quick to do with the jQuery UI progress bar, just call this initially:

$("#progressbar").progressbar({ value: 0 });

And this in your other script, probably via setInterval():

var percentComplete = 40; //Get the percent
$("#progressbar").progressbar( { value: percentComplete } );

Put it together like this:

var percentComplete = 0; //Update this in your other script
$("#progressbar").data("progress", setInterval(function() {
  if(percentComplete == 100) {
    percentComplete = 0;
    clearInterval($("#progressbar").data("progress")); //Stop updating
  }
  $("#progressbar").progressbar( { value: percentComplete } );
}, 200));

The animated effect keeps it a bit smoother looking as well: see here for a demo. This is done via a single CSS rule, in the demo case:

.ui-progressbar-value { background-image: url(images/pbar-ani.gif); }

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1744808717a4594935.html

相关推荐

  • jquery - Continuous Progress Bar in Javascript - Stack Overflow

    I am trying to find the best option to create a simple progress bar that I need to be triggered periodi

    2天前
    30

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信