Answer the question
In order to leave comments, you need to log in
How to make a custom delay in setTimeout?
Good day!
I'm trying to make an object oriented modal window that would
this.overlay.style.display = "block";
this.modal.style.display = "flex";
setTimeout(() => {
this.overlay.style.opacity = "1";
this.modal.style.opacity = "1";
}, 1); // без этой задержки не работает плавное появление
this.overlay.style.opacity = "0";
this.modal.style.opacity = "0";
setTimeout(() => {
this.overlay.style.display = "none";
this.modal.style.display = "none";
}, this.fadeTime);
/* если задержка указана так - то окно пропадает сразу,
а если задержку указать явно (1000) - то через display:none случится только через 1 сек..*/
Answer the question
In order to leave comments, you need to log in
It seems to me that there is an error in scope. In this block, there is simply no fadeTime in this
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question