Fix revealing spoilers when animation is disabled

This commit is contained in:
Eduard Kuzmenko 2022-01-18 19:55:30 +04:00
parent acf06c24fd
commit cca5e6f0e2
2 changed files with 20 additions and 5 deletions

View File

@ -1060,15 +1060,24 @@ export default class ChatBubbles {
const duration = 400 / 2; const duration = 400 / 2;
const showDuration = 5000; const showDuration = 5000;
const useRafs = !isVisible ? 1 : 0; const useRafs = !isVisible ? 2 : 0;
if(useRafs) { if(useRafs) {
messageDiv.classList.add('will-change'); messageDiv.classList.add('will-change');
} }
SetTransition(messageDiv, className, true, duration + showDuration, () => { const spoilerTimeout = messageDiv.dataset.spoilerTimeout;
SetTransition(messageDiv, className, false, duration, () => { if(spoilerTimeout !== null) {
messageDiv.classList.remove('will-change'); clearTimeout(+spoilerTimeout);
}); delete messageDiv.dataset.spoilerTimeout;
}
SetTransition(messageDiv, className, true, duration, () => {
messageDiv.dataset.spoilerTimeout = '' + window.setTimeout(() => {
SetTransition(messageDiv, className, false, duration, () => {
messageDiv.classList.remove('will-change');
delete messageDiv.dataset.spoilerTimeout;
});
}, showDuration);
}, useRafs); }, useRafs);
return; return;

View File

@ -63,4 +63,10 @@
} }
} }
} }
&:not(.is-spoiler-visible) {
.spoiler {
cursor: pointer;
}
}
} }