Skip to content
A simple way to toggle loading state.
JavaScript CSS
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.
test
.gitignore
History.md
Makefile
Readme.md
component.json
index.js

Readme.md

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

Something went wrong with that request. Please try again.