Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function fadeOut(selector, time){
- let timer = time || 400;
- let element = document.querySelectorAll(selector)[0];
- let timeForSetInterver = 20;
- let opacityStart = getComputedStyle(element).opacity;
- let count = timer / timeForSetInterver;
- let step = opacityStart / count;
- let i = 0;
- let forClear = setInterval(function(){
- let opacity = getComputedStyle(element).opacity;
- element.style.opacity = parseFloat(opacity) - parseFloat(step);
- i++;
- if(i == count){
- clearInterval(forClear);
- element.style.opacity = 0;
- }
- }, timeForSetInterver)
- }
Add Comment
Please, Sign In to add comment