最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - Do you have any Ajax loading image ideas for use with jQuery? - Stack Overflow

programmeradmin1浏览0评论

I have a page being loaded with jQuery. The initial load includes 100 records with 6 icons per record. Needless to say, it takes a few seconds to load and I want to give the user a "loading" prompt/animation.

Any ideas?

I have a page being loaded with jQuery. The initial load includes 100 records with 6 icons per record. Needless to say, it takes a few seconds to load and I want to give the user a "loading" prompt/animation.

Any ideas?

Share Improve this question edited Oct 9, 2008 at 19:15 Jason Bunting 58.9k15 gold badges104 silver badges94 bronze badges asked Oct 9, 2008 at 18:54 Gene RGene R 1,5655 gold badges20 silver badges33 bronze badges
Add a comment  | 

7 Answers 7

Reset to default 11

http://www.ajaxload.info/ is a great resource for generating animated GIFs for this sort of thing.

Once you've got your animation, render it as part of the page; fire the jQuery load mechanism on the animation's onload() event (so you're certain the animation has loaded first), and use a callback at the end of your loading sequence to disable/hide the animated GIF.

Matt Berseth has a nice jQuery-based way of doing this.

Another ressource for loading images : http://www.loadinfo.net/

You could display a div with an animated GIF image as a loading prompt. That's the way I've done it in the past.

Any time I've needed something like this I replace the element that will be loaded with a simple, centered, animated gif of some sort that says "Loading, please wait" or a similar message. If it's only going to be a few seconds a progress indicator is probably overkill, but a simple animation gives most people the assurance that, yes, your site is still working.

You may want to set up a global ajax event to show/hide the loading icon. Have a look at: http://docs.jquery.com/Ajax_Events

You can do a animation in CCS3, for example if you want a pulse:

The html markup:

<div class="pulse"></div>

The css:

.pulse {
    width: 32px;
    height: 32px;
    margin: 25% auto;
    background-color: #303030;
    -webkit-border-radius: 16px;
    -moz-border-radius: 16px;
    -ms-border-radius: 16px;
    -o-border-radius: 16px;
    border-radius: 16px;
    -webkit-animation: scaleout 1.0s infinite ease-in-out;
    animation: scaleout 1.0s infinite ease-in-out;
}
@-webkit-keyframes scaleout{
    0%{
        -webkit-transform:scale(0)
    }
    100%{
        -webkit-transform:scale(1);
        opacity:0
    }
}
@-moz-keyframes scaleout{
    0%{
        -moz-transform:scale(0)
    }
    100%{
        -moz-transform:scale(1);
        opacity:0
    }
}
@-ms-keyframes scaleout{
    0%{
        -ms-transform:scale(0)
    }
    100%{
        -ms-transform:scale(1);
        opacity:0
    }
}
@-o-keyframes scaleout{
    0%{
        -o-transform:scale(0)
    }
    100%{
        -o-transform:scale(1);
        opacity:0
    }
}
@keyframes scaleout{
    0%{
        transform:scale(0);
        -webkit-transform:scale(0)
    }
    100%{
        transform:scale(1);
        -webkit-transform:scale(1);
        opacity:0
    }
}

Or you can create a div with inside image or background image,you have here a few ideas for animation, it have a downloadable set free, enjoy.

发布评论

评论列表(0)

  1. 暂无评论