Circular progress indicator with jQuery

2019-01-16 10:21发布

I need circular progress indicator. How should I implement this?

What I'm looking for is what jQuery UI has in their planning page, but its not yet implemented. I'm just curious if anyone has implemented this before. See item 6 in following image.

alt text

http://wiki.jqueryui.com/ProgressIndicator

4条回答
欢心
2楼-- · 2019-01-16 10:48

Like, one of these? You don't need a plugin for that. Just .show() and .hide() a GIF as necessary (or insert it into the DOM, whatever floats your boat).

查看更多
一夜七次
3楼-- · 2019-01-16 10:49

You could use jQuery to slide the background position around, and use or create the appropriate css sprite image table for it.

of course you'd need to have 100 sprite cells, and then you'd need to compile a list of background position co-ords into an multi-dimensional array/table/dictionary.

progressMeterSpriteCoords = [
 {x: 0, y: 0},      //0%
 {x: -16, y: 0},    //1%
 {x: -32, y: 0},    //2%
  ... etc etc..
 {x: -320, y: -0},  //19%
 {x: 0, y: -16},    //20%
 {x: -16, y: -16},  //21%
 {x: -32, y: -16},  //22%
  ... etc etc..
 {x: -320, y: -16}, //29%
  ... etc etc..
 {x: -320, y: -320} //99%
]
查看更多
Viruses.
4楼-- · 2019-01-16 10:57

Not jQuery, but you might want to take a look at the Raphaël javascript library, and in-particular the polar clock example, and the 'arc' custom attribute. I've used Raphaël and jQuery together to generate some static circular progress bars before - it works quite nicely.

查看更多
Luminary・发光体
5楼-- · 2019-01-16 11:00

What are you loading? A basic example would be:

<div id="loading"></div>
<a href="javascript:void(0);" id="load">Load!</a>

<script type="text/javascript">
    $('#load').click(function(){ // click event on the load link
        $('#loading').html('<img src="/path/to/animation.gif" />'); // display a loading animation where the content goes
        $.get('/file/to/load.php', function(data) { // request content to be displayed
            $('#loading').html(data); // display content
        });
    });
</script>

Cheers

查看更多
登录 后发表回答