test-assignment-loader
v1.0.4
Published
Easy to use loader that provides control API
Downloads
4
Readme
Test assignment loader
How to use:
- Download using
npm install test-assignment-loader
- Import the
testAssignmentLoader
function fromnode_modules
- Create your loader, passing a container to the function
testAssignmentLoader takes the following arguments:
container
- an HTML element to put the loader intoinitialValue
- initial value of the loader- A state object. The shape of the object and the default values look like this:
{initialAnimated: false, initialHidden: false}
testAssignmentLoader returns an object, that allows you to control the loader's state. There are three functions in that object:
setValue(value)
- to set a new value for the loader, tries to convertvalue
to a number, setting it to0
if it can'tsetAnimated(animated)
- to set whether or not the loader is spinning. Convertsanimated
to a boolean.setHidden(hidden)
- to set whether or not the loader is visible. Convertshidden
to a boolean.
Example
Here's how you could use testAssignmentLoader:
const container = document.querySelector('.loader-container');
const loader = testAssignmentLoader(container, 50, {
initialAnimated: true,
});
const valueInput = document.querySelector('#value-input');
valueInput.addEventListener('input', (e) => {
loader.setValue(e.target.value);
});