diff --git a/internal/webserver/static/styles.css b/internal/webserver/static/styles.css index fec16cd..c5b70cb 100644 --- a/internal/webserver/static/styles.css +++ b/internal/webserver/static/styles.css @@ -1268,14 +1268,13 @@ main { * margin: 0.5em 0; */ + /* When a replying-to box is clicked, it scrolls that message into view and highlights it for a second */ transition: background-color 2s ease; - &.highlighted { background-color: var(--color-twitter-off-white-dark); transition: background-color 0.5s ease; } - .dm-message__row { align-items: stretch; diff --git a/internal/webserver/tpl/tweet_page_includes/chat_view.tpl b/internal/webserver/tpl/tweet_page_includes/chat_view.tpl index 8974f51..c02f075 100644 --- a/internal/webserver/tpl/tweet_page_includes/chat_view.tpl +++ b/internal/webserver/tpl/tweet_page_includes/chat_view.tpl @@ -81,22 +81,6 @@ {{end}} - {{end}} {{define "messages-with-poller"}} @@ -196,6 +180,21 @@ // Scroll to the bottom of the chat window on initial page load chat_messages.scrollTop = chat_messages.scrollHeight; })(); + + /** + * Define callback on-click handler for 'replying-to' previews; they should scroll the replied-to + * message into view, if possible. + */ + function doReplyTo(replying_to_box) { + const replied_to_id = replying_to_box.getAttribute("data-replying-to-message-id"); + const replied_to_message = document.querySelector('[data-message-id="' + replied_to_id + '"]'); + + replied_to_message.scrollIntoView({behavior: "smooth", block: "center"}); + replied_to_message.classList.add("highlighted"); + setTimeout(function() { + replied_to_message.classList.remove("highlighted"); + }, 1000); + } {{end}} @@ -234,4 +233,19 @@ {{define "messages-top"}} {{template "conversation-top" .}} {{template "messages" .}} + {{end}}