From a28981de7c5ba5cff6ab4ef57b5494ba7fa7825b Mon Sep 17 00:00:00 2001 From: Julian Lam Date: Fri, 9 Dec 2022 16:07:47 -0500 Subject: [PATCH] feat: unread indicator in topic nav --- public/src/client/topic/glance.js | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/public/src/client/topic/glance.js b/public/src/client/topic/glance.js index 01fec7e621..5089e7f08b 100644 --- a/public/src/client/topic/glance.js +++ b/public/src/client/topic/glance.js @@ -22,6 +22,7 @@ export default function init() { navigatorEl.classList.toggle('d-sm-flex', true); enableButtons(); ({ handleEl } = enableHandle()); + updateUnreadIndicator(); once('action:ajaxify.cleanup', () => { navigatorEl.classList.toggle('d-sm-flex', false); @@ -90,6 +91,13 @@ function enableHandle() { return { handleEl }; } +function updateUnreadIndicator() { + const unreadEl = document.querySelector('[component="topic/navigator"] .unread'); + const percentage = 1 - (ajaxify.data.bookmark / ajaxify.data.postcount); + + unreadEl.style.height = `${trackHeight * percentage}px`; +} + function repositionHandle(index) { // Updates the position of the handle on the track based on viewport if (!index) { @@ -99,6 +107,7 @@ function repositionHandle(index) { } updateHandleText(); + updateUnreadIndicator(); if (index === 0) { handleEl.style.top = 0;