I wanna create some loading dots, like this:
At 0000 miliseconds the span content is: .
At 0100 miliseconds the span content is: ..
At 0200 miliseconds the span content is: ...
In a loop.
What is the best / easiest way to make it?
I wanna create some loading dots, like this:
At 0000 miliseconds the span content is: .
At 0100 miliseconds the span content is: ..
At 0200 miliseconds the span content is: ...
In a loop.
What is the best / easiest way to make it?
Or.. you can do it with CSS ;)
Codepen sample
In my mind, the easiest way is an
if
/else
statement.However, a bit math to calculate the dots-length and the famous
Array.join
-hack to repeat the dot-char, should do the trick too.You could improve the readability a bit, by wrapping the "count-up-and-down"-part and "string-repetition" in separate functions.
Example: http://jsfiddle.net/subTZ/
This is similar to Veiko Jääger's solution. With this solution, the color of the dots is the same as the text it associates with.
Example: https://codepen.io/lukaszkups/pen/NQjeVN
You can animate css
content
too!Or you can get fancy and have them go forward and back:
Or you could make them go back and forth randomly:
Or I could get a life and stop posting additional snippets.... :D
As Ivo said in the comments, you need to clear the interval at some point, especially if you are not loading a new page after the waiting is finished. :D