Accessible Loading Indicator With jQuery - hg-loading

Accessible Loading Indicator With jQuery - hg-loading
File Size: 6.61 KB
Views Total:
Last Update:
Publish Date:
Official Website: Go to website
License: MIT
   

hg-loading is a simple jQuery loader plugin which displays a customizable loading spinner when waiting for something to be loaded in the document. With appropriate ARIA roles for accessibility.

How to use it:

1. To get started, include the hg-loading plugin after jQuery.

<script src="https://code.jquery.com/jquery-3.3.1.min.js" 
        integrity="sha384-tsQFqpEReu7ZLhBV2VZlAu7zcOV+rXbYlF2cqB8txI/8aZajjp4Bqd+V6D5IgvKT" 
        crossorigin="anonymous">
</script>
<script src="assets/js/loader.js"></script>

2. Show the loading indicator.

$.showLoading();

3. Apply fadeIn and fadeOut animations to the loading indicator.

.hg-loading {
  background: #c1c1c1;
  width: 100%;
  height: 100%;
  position: fixed;
  top: 0;
  left: 0;
  z-index: 100;
  opacity: 0;
  transition: opacity .2s;
}

.hg-loading.fade{
  opacity: 1;
  transition: opacity .2s;
}

.loading-body {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 75px;
  height: 75px;
  margin-left: -35px;
  margin-top: -35px;
}

4. Hide the loading indicator.

$.hideLoading();

5. Override the default loading spinner.

$.showLoading({
  imgLoading: '/path/to/loading.svg'
});

6. More configuration options with default values.

$.showLoading({

  // body html
  body: "",

  // loading class
  loadingClass: "fade",

  // dialog class
  loadingDialogClass: ""
  
});

7. Available callback functions.

$.showLoading({

  // fired after the Loading was created
  onCreate: null, 

  // fired after the Loading was disposed
  onDispose: null

});

This awesome jQuery plugin is developed by heldergonzaga. For more Advanced Usages, please check the demo page or visit the official website.