From cca5e6f0e2f6faa45551d6650aef616e0209def2 Mon Sep 17 00:00:00 2001 From: Eduard Kuzmenko Date: Tue, 18 Jan 2022 19:55:30 +0400 Subject: [PATCH] Fix revealing spoilers when animation is disabled --- src/components/chat/bubbles.ts | 19 ++++++++++++++----- src/scss/partials/_spoiler.scss | 6 ++++++ 2 files changed, 20 insertions(+), 5 deletions(-) diff --git a/src/components/chat/bubbles.ts b/src/components/chat/bubbles.ts index 4d94b42e..1d11d766 100644 --- a/src/components/chat/bubbles.ts +++ b/src/components/chat/bubbles.ts @@ -1060,15 +1060,24 @@ export default class ChatBubbles { const duration = 400 / 2; const showDuration = 5000; - const useRafs = !isVisible ? 1 : 0; + const useRafs = !isVisible ? 2 : 0; if(useRafs) { messageDiv.classList.add('will-change'); } - SetTransition(messageDiv, className, true, duration + showDuration, () => { - SetTransition(messageDiv, className, false, duration, () => { - messageDiv.classList.remove('will-change'); - }); + const spoilerTimeout = messageDiv.dataset.spoilerTimeout; + if(spoilerTimeout !== null) { + 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); return; diff --git a/src/scss/partials/_spoiler.scss b/src/scss/partials/_spoiler.scss index 2b063511..6745eef8 100644 --- a/src/scss/partials/_spoiler.scss +++ b/src/scss/partials/_spoiler.scss @@ -63,4 +63,10 @@ } } } + + &:not(.is-spoiler-visible) { + .spoiler { + cursor: pointer; + } + } }