Skip to content
This repository was archived by the owner on Mar 8, 2019. It is now read-only.

ianstormtaylor/loading

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

loading

A simple way to toggle loading state.

It will toggle a "loading" class on an element, and return a function that removes it. By default, it waits 200ms to add the loading class, so that you don't make your interface feel slow.

Installation

$ component install ianstormtaylor/loading

Example

var loading = require('loading');
var loaded = loading(document.body); // adds `.loading` to body

Model.get(1, function (err, model) {
  // do stuff  
  loaded(); // removes `.loading` from body
});

API

loading(el, [delay])

Add a 'loading' class to an element after an optional delay, and return a function that will remove it. delay defaults to 200 milliseconds.

License

MIT

About

A simple way to toggle loading state.

Resources

Stars

Watchers

Forks

Packages

No packages published