AnimationsUtiles.js

Usage



                                    


                                    


                                    
# animateValue

This function displays a transition between a range of numbers in a DOM element

Code

    
                                    
Example
Number:
# elementTransition

This function make a transition for show or hide a element

Code

    
                                    
Example
Product Name Code Action
# loadingButton

This function disable a button and displays a custom text next to a spinner based on button text

Code
/**
 * This function disable a button and displays a custom text next to a spinner based on button text
 * 
 * @param {element} btn button element DOM
 * @param {string} action action of button
 * @param {string} text text of button
 */ 
const loadingButton = (btn, action, text = null) => {
    switch (action) {
        case 'start':
            btn.setAttribute('data-btn-text', btn.innerHTML);
            btn.innerHTML = `<span class="spinner-loading"></span> ${text}`;
            btn.disabled = true;
            break;
        case 'stop':
            btn.innerHTML = btn.getAttribute('data-btn-text');
            btn.disabled = false;
            break;
    }
}
Example