Customized loading animation (not your average GIF)

There are numerous websites on the internet where you can customize a loading GIF, but I was curious if there is another way to create custom text for loading animations without using Adobe software.

Instead of the common spinner, I am interested in specifying text that animates while an image loads.

I have searched extensively and have not found a solution. The closest I found was a jQuery spinner, but it's not what I'm looking for.

Have any of you encountered this before? If so, how did you customize it?

For example:

Sometimes you might see the following animated as a GIF:

L......

LO.....

LOA....

LOAD...

LOADI..

LOADIN.

LOADING

The above animation is created by looping through different frames, but I wonder if there is a more modern method to create custom loading messages, possibly using jQuery or other technologies instead of Flash.

Answer №1

Is this similar to what you're looking for?

var $ld = $('#loading-container');
var count = 1;
var text = "Loading...";
var loadingAnimation = setInterval(function(){
    $ld.text(text.substr(0, count));
    count++;
    if (count > text.length)
        count = 1;
}, 100);

Make sure to include clearTimeout(loadingAnimation) when finished.

See demo here: http://www.example.com/demo123

Answer №2

Avoiding the use of jQuery:

<div id="loading"></div>

.

function loadingContent(element, string, time) {
    const timeout = 200; // milliseconds
    if (arguments.length == 2) time = string;
    switch (string) {
        case '':
            element.innerHTML = '';
            loadingContent(element, time, time);
            break;
        default:
            element.innerHTML += string.charAt(0);
            setTimeout(function() {
                loadingContent(element, string.substr(1), time);
            }, timeout);
    }
}

loadingContent(document.getElementById('loading'), 'NOW LOADING...');

http://jsfiddle.net/SHiNKiROU/Su2hy/

UPDATE: Implementing dots padding for the loading message

<div id="loading" style="font-family: monospace;"></div>

.

function addDotsPadding(element, string) {
        const timeout = 200; // milliseconds
        var index = 0;

        function displayTextWithDots(i) {
            var textToShow = '';
            for (var j = 0; j <= i; j++) {
                textToShow += string.charAt(j);
            }
            for (var j = i + 1; j < string.length; j ++) {
                textToShow += '.';
            }
            element.innerHTML = textToShow;
        }
        return setInterval(function() {
            displayTextWithDots(index++);
            if (index == string.length) index = 0;
        }, timeout);
}

var interval = addDotsPadding(document.getElementById('loading'), 'LOADING');
// clearInterval(interval); when loading is complete

http://jsfiddle.net/SHiNKiROU/Su2hy/9/

Answer №3

Check out the jQuery plugin featured on CSS-Tricks for loading dots.

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Is it possible for PHP to use the set cookie function to replace the cookie value set by JQuery cookie?

I'm facing an issue where I want a single cookie to be set and its value updated by PHP when a user logs in. However, currently it seems to just create a new separate cookie each time. Below is the code snippet where I am trying to set the cookie valu ...

Send the data from the table to the controller

As a beginner in programming, I am trying to send a table input value to the controller. I have attempted the following method: $("#btnsend").click(function () { $.ajax({ type: "POST", contentType: "application/json ; charset=utf-8", ...

CSS: Targeting a particular instance of a specific element type within an HTML document

My goal is to target specific occurrences of a certain type of element in CSS for styling purposes. Consider the following example: <span>Some random stuff</span> <p>Occurrence 1 of p</p> <ul> <li>Random stuff</li&g ...

How can we use jQuery to change the format of a

I'm working on a project where I want the calendar to display the date that the user picks. Right now, my "{{date}}" is in the format 2016-01-11, but it keeps showing one day before the selected date. I would like it to display as mm/dd/yyyy. I belie ...

Is it possible to merge two HTML selectors using jQuery?

In my HTML, I have two button elements defined as follows: <input type="button" class="button-a" value="Button a"/> <input type="button" class="button-b" value="Button b"/> When either of these buttons is clicked, I want to trigger the same ...

Enhance Your Page with a Widget Using Bootstrap

I am looking to incorporate a basic text box on the side of my webpage. https://i.sstatic.net/qzwIh.png Currently, I have a table on the page. Upon adding the widget, I need the table to reduce its width. ...

Comparing the Usage of Forward Slash [/] and Space in CSS

I'm a bit confused about when to use certain CSS syntaxes. For instance, I've come across: border: 2px solid red; as opposed to: border-width: 2px; border-style: solid; border-color: red; However, I've also seen: font: 12px/18px; rather t ...

Triggering JavaScript events using jQuery

I am experiencing an issue with an input element that triggers a modal containing a table when clicked. From this table, you can select a line and a JavaScript function modifies the value of the input element accordingly. However, I am trying to detect the ...

What is the best method for making recursive ajax calls until a specific condition is met?

I need help with a recursive AJAX method that should keep calling until the variable maxnumId is empty or undefined. Currently, my code only runs once. Can anyone point out what I might be doing wrong here? Thank you! Here's the code snippet: <sc ...

Utilizing a jQuery hint plugin with ASP.NET MVC3's client-side validation feature

What I mean by a jQuery hint plugin is one that displays guiding text like "Please enter your name here..." inside an input field. However, when using such a plugin with jQuery ASP.NET MVC client-side validation, it may end up validating the input against ...

The HTML elements in my JSX code seem to constantly shift around whenever I resize my webpage

Using react.js, I'm currently developing a website that appears like this before resizing: pre-resize_screenshot_website However, upon vertical or diagonal resizing, the layout becomes distorted especially in the 'availability search bar' ...

A guide on transforming a string into an object and utilizing it

In my custom plugin, I have set up a function with default options like this: $.fn.customPlugin = function( options ) { var settings = $.extend({ amazon: "", download: "some text", purchase: "", ...

How can you make a dropdown button interactive and display a list simultaneously?

I'm facing an issue with lines 45-47 in the second link. If that code is present, the button animates when clicked (which is great) BUT the dropdown items ("About," "Archive," "Contact") do not appear. If I remove lines 45-47, the dropdown items appea ...

Sending PHP variables to jQuery AJAX in a separate script-file

My goal is to transfer variables from PHP to jQuery in order to confirm the success of an INSERT query. Initially, the $msg variable is set as an empty string. Once the mysqli_num_rows if statement evaluates to true, the $msg variable will no longer be emp ...

Submitting an ajax form with the use of the symbol '&'

I am currently working on a form submission using the .ajax() method. Within my script, I have the following code: data: dataString, The variable dataString is composed of: var list = $('.listsummary').val() The listsummary class is assoc ...

AmCharts Axis renderer mistakenly renders an additional grid line

I have successfully created a basic XYChart using amcharts4. To get rid of the grid lines on the x-axis, I changed the stroke opacity for the x-axis grid to 0 using the following code: xAxis.renderer.grid.template.strokeOpacity = 0; Everything was workin ...

Please select the links located beneath the see-through triangular or polygonal shapes

Review the code snippet provided at the following link: http://jsfiddle.net/q8Ycz <div style="background-color: red; width: 200px;" onclick="alert('behind')"> <div><a href="test">test test test test test test test test test ...

Can Masonry.js content be perfectly centered?

I am currently experimenting with creating a layout consisting of one to four variable columns per page using the Masonry plugin. I have been impressed with how it functions so far. However, there is an aggravating gap that persists despite my best effort ...

How can I deactivate a specific range without altering the appearance with Bootstrap 5?

My challenge lies in maintaining the style of a range input while disabling user interaction with it. I've tried to recreate the original styling manually, but without success: <!DOCTYPE html> <html lang="en"> <head> <!-- ...

The `val()` method in jQuery does not retrieve the value from every input field

Here is the HTML code I am working with: <input type="text" id="fname" name="fname" placeholder="First Name" /> <input type="text" id="lname" name="lname" placeholder="Last Name" /> <input type="text" id="birthdate" name="birthdate" placeho ...