Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Basic jQuery animation: Elipsis (three dots sequentially appearing)

What I need:

I need an animated elipisis (...), one dot appearing after the other. The animation needs to loop. I'd like to achieve this via jQuery

Animation sequence:

Frame 1: Awaiting your selection

Frame 2: Awaiting your selection .

Frame 3: Awaiting your selection ..

Frame 4: Awaiting your selection ...

What I've tried:

I've been researching a plugin to blink text and the pulsate .effect().

My question:

Does anyone have any reccomendations on the simplest and most reliable means of achieving this? I'd be happy to be pointed to a technique or function.

like image 641
Dominor Novus Avatar asked Oct 21 '12 09:10

Dominor Novus


1 Answers

If you just need the dots to appear one after another only once, try something very simple like the following:

<div id="message">Awaiting your selection</div>​

var dots = 0;

$(document).ready(function() {
    setInterval (type, 600);
});

function type() {
    if(dots < 3) {
        $('#message').append('.');
        dots++;
    }
}​

http://jsfiddle.net/fVACg/

If you want them to appear more than once (to be deleted and then re-printed), you can do something like the following:

<div>Awaiting your selection<span id="dots"></span></div>​

var dots = 0;

$(document).ready(function() {
    setInterval (type, 600);
});

function type() {
    if(dots < 3) {
        $('#dots').append('.');
        dots++;
    } else {
        $('#dots').html('');
        dots = 0;
    }
}​

http://jsfiddle.net/wdVh8/

Finally, checkout a tutorial I've written a few years ago. You might find it useful.

like image 136
StathisG Avatar answered Nov 16 '22 17:11

StathisG