From 69c0cad14cec145d2369f649a2a7df6766847288 Mon Sep 17 00:00:00 2001 From: ayumi-signal <143036029+ayumi-signal@users.noreply.github.com> Date: Mon, 2 Oct 2023 16:18:28 -0400 Subject: [PATCH] Only animate typing when viewing conversation --- stylesheets/_modules.scss | 17 ++++---- ts/components/conversation/TypingBubble.tsx | 46 ++++++++++++++++----- ts/util/lint/exceptions.json | 22 ++++++---- 3 files changed, 59 insertions(+), 26 deletions(-) diff --git a/stylesheets/_modules.scss b/stylesheets/_modules.scss index 884dd13c936..c8dd2507d6e 100644 --- a/stylesheets/_modules.scss +++ b/stylesheets/_modules.scss @@ -1384,6 +1384,11 @@ $message-padding-horizontal: 12px; &--with-reactions { padding-bottom: 15px; } + + &--typing { + flex-direction: row-reverse; + overflow-y: clip; + } } .module-message__container-outer--typing-bubble { @@ -1391,16 +1396,8 @@ $message-padding-horizontal: 12px; } .module-message__typing-avatar-container { - align-items: center; - display: flex; flex-direction: row-reverse; - justify-content: center; - margin-inline-end: 8px; overflow-y: clip; - - &--with-reactions { - padding-bottom: 15px; - } } .module-message__typing-avatar { @@ -2848,6 +2845,10 @@ button.module-image__border-overlay:focus { padding-inline: 1px; } +.module-message__typing-animation-container .module-typing-animation { + width: 30px; +} + .module-typing-animation__dot { border-radius: 50%; diff --git a/ts/components/conversation/TypingBubble.tsx b/ts/components/conversation/TypingBubble.tsx index 555d6a680d1..98efd4e2e85 100644 --- a/ts/components/conversation/TypingBubble.tsx +++ b/ts/components/conversation/TypingBubble.tsx @@ -44,8 +44,8 @@ export type TypingBubblePropsType = { const SPRING_CONFIG = { mass: 1, - tension: 986, - friction: 64, + tension: 439, + friction: 42, precision: 0, velocity: 0, }; @@ -53,17 +53,15 @@ const SPRING_CONFIG = { const AVATAR_ANIMATION_PROPS: Record<'visible' | 'hidden', object> = { visible: { opacity: 1, - scale: 1, width: '28px', x: '0px', top: '0px', }, hidden: { opacity: 0.5, - scale: 0.5, width: '4px', // Match value of module-message__typing-avatar margin-inline-start x: '14px', - top: '30px', + top: '34px', }, }; @@ -71,6 +69,7 @@ function TypingBubbleAvatar({ conversationId, contact, visible, + shouldAnimate, getPreferredBadge, onContactExit, showContactModal, @@ -80,6 +79,7 @@ function TypingBubbleAvatar({ conversationId: string; contact: TypingContactType | undefined; visible: boolean; + shouldAnimate: boolean; getPreferredBadge: PreferredBadgeSelectorType; onContactExit: (id: string | undefined) => void; showContactModal: (contactId: string, conversationId?: string) => void; @@ -89,7 +89,9 @@ function TypingBubbleAvatar({ const [springProps, springApi] = useSpring( { config: SPRING_CONFIG, - from: AVATAR_ANIMATION_PROPS[visible ? 'hidden' : 'visible'], + from: shouldAnimate + ? AVATAR_ANIMATION_PROPS[visible ? 'hidden' : 'visible'] + : {}, to: AVATAR_ANIMATION_PROPS[visible ? 'visible' : 'hidden'], onRest: () => { if (!visible) { @@ -138,6 +140,7 @@ function TypingBubbleAvatar({ function TypingBubbleGroupAvatars({ conversationId, typingContactIds, + shouldAnimate, getConversation, getPreferredBadge, showContactModal, @@ -153,6 +156,7 @@ function TypingBubbleGroupAvatars({ | 'theme' > & { typingContactIds: ReadonlyArray; + shouldAnimate: boolean; }): ReactElement { const [allContactsById, setAllContactsById] = useState< Map @@ -195,7 +199,7 @@ function TypingBubbleGroupAvatars({ // Avatars are rendered Right-to-Left so the leftmost avatars can render on top. return ( -
+
{typingContactsOverflowCount > 0 && (