Skip to content

armgit / zulip

Public Imported from GitHub
0

Zulip server and web application. Open-source team chat that helps teams stay productive and focused.

left_sidebar: Change animation for new unread mentions.

Karl Stolley4289cb67e572
diff --git a/web/src/left_sidebar_navigation_area.ts b/web/src/left_sidebar_navigation_area.ts
index e2ac1699dbf..217f900cdd6 100644
--- a/web/src/left_sidebar_navigation_area.ts
+++ b/web/src/left_sidebar_navigation_area.ts
@@ -174,22 +174,36 @@ function toggle_condensed_navigation_area(): void {
export function animate_mention_changes($li: JQuery, new_mention_count: number): void {
if (new_mention_count > last_mention_count) {
- do_new_messages_animation($li);
+ do_new_unread_animation($li);
}
last_mention_count = new_mention_count;
}
-function do_new_messages_animation($li: JQuery): void {
- $li.addClass("new_messages");
- function mid_animation(): void {
- $li.removeClass("new_messages");
- $li.addClass("new_messages_fadeout");
- }
- function end_animation(): void {
- $li.removeClass("new_messages_fadeout");
- }
- setTimeout(mid_animation, 3000);
- setTimeout(end_animation, 6000);
+function do_new_unread_animation($target: JQuery): void {
+ // The .new-unread-highlight class manages the
+ // transition on the target element's background.
+ // The pulse effect on unread counts, by contrast,
+ // is handled via CSS animations on the .new-unread
+ // class.
+ $target.addClass("new-unread new-unread-highlight");
+ // We listen for the end of the animation to remove
+ // the .new-unread class; this allows us to express
+ // exclusively in CSS our desired timing, duration,
+ // and any other effects. Doing so also gives us
+ // very smooth rendering, as no visual properties
+ // get tied to JavaScript's event loop.
+ $target.on("animationend", (): void => {
+ $target.removeClass("new-unread");
+ // We remove the transition-managing highlight
+ // some time after the animation has run; how
+ // long after doesn't really matter, as the
+ // transition will run as soon as .new-unread
+ // is removed above. This just ensures that we
+ // *do* see a transition on the background color.
+ setTimeout(() => {
+ $target.removeClass("new-unread-highlight");
+ }, 2000);
+ });
}
export function highlight_inbox_view(): void {
diff --git a/web/styles/left_sidebar.css b/web/styles/left_sidebar.css
index 3c4baa1e3b6..2b340a6e7f6 100644
--- a/web/styles/left_sidebar.css
+++ b/web/styles/left_sidebar.css
@@ -912,7 +912,23 @@ li.active-sub-filter {
}
}
-#stream_filters .narrow-filter.active-filter {
+.top_left_mentions {
+ /* To highlight the background when a new unread arrives,
+ we set the background on the .new-unread class. */
+ &.new-unread {
+ background-color: var(--color-background-active-narrow-filter);
+ }
+ /* The background-color transition is maintained by this class,
+ which ensures an immediate opening transition, and lingers
+ some time longer beyond the CSS Animation on the unread count,
+ ensuring a smooth transition back to the normal background
+ color on the sidebar row that's been targeted. */
+ &.new-unread-highlight {
+ transition: background-color 1s ease-in-out;
+ }
+}
+
+.top_left_mentions #stream_filters .narrow-filter.active-filter {
.topic-list .filter-topics,
> .bottom_left_row {
background-color: var(--color-background-active-narrow-filter);
diff --git a/web/styles/zulip.css b/web/styles/zulip.css
index 7e5fd83db51..4e7d7d363a3 100644
--- a/web/styles/zulip.css
+++ b/web/styles/zulip.css
@@ -843,13 +843,22 @@ strong {
position: relative;
}
-.new_messages {
- background-color: hsl(194deg 53% 79%);
+@keyframes pulse-unread {
+ 0% {
+ transform: scale(1);
+ }
+
+ 50% {
+ transform: scale(1.5);
+ }
+
+ 100% {
+ transform: scale(1);
+ }
}
-.new_messages,
-.new_messages_fadeout {
- transition: background-color 3s ease-in-out;
+.new-unread .unread_count {
+ animation: 2s ease-in-out 2 pulse-unread;
}
.messagebox-content .slow-send-spinner {