diff options
Diffstat (limited to 'Omni/Jr/Web/Components.hs')
| -rw-r--r-- | Omni/Jr/Web/Components.hs | 20 |
1 files changed, 14 insertions, 6 deletions
diff --git a/Omni/Jr/Web/Components.hs b/Omni/Jr/Web/Components.hs index 2f885ce..ac36131 100644 --- a/Omni/Jr/Web/Components.hs +++ b/Omni/Jr/Web/Components.hs @@ -1730,14 +1730,22 @@ timelineScrollScript = ] ( Text.unlines [ "(function() {", - " if (typeof autoscrollEnabled !== 'undefined' && !autoscrollEnabled) return;", - " var log = document.querySelector('.timeline-events');", - " if (log) {", - " var isNearBottom = log.scrollHeight - log.scrollTop - log.clientHeight < 100;", - " if (isNearBottom) {", - " log.scrollTop = log.scrollHeight;", + " function scrollToBottom() {", + " if (typeof autoscrollEnabled !== 'undefined' && !autoscrollEnabled) return;", + " var log = document.querySelector('.timeline-events');", + " if (log) {", + " var isNearBottom = log.scrollHeight - log.scrollTop - log.clientHeight < 100;", + " if (isNearBottom) {", + " log.scrollTop = log.scrollHeight;", + " }", " }", " }", + " scrollToBottom();", + " document.body.addEventListener('htmx:afterSwap', function(e) {", + " if (e.target.closest('.timeline-events') || e.target.classList.contains('timeline-events')) {", + " scrollToBottom();", + " }", + " });", "})();" ] ) |
