From c59f2dde998e4383cf9fbe0af48b1e47ca610c54 Mon Sep 17 00:00:00 2001 From: iou1name Date: Sun, 22 Jul 2018 02:58:54 -0400 Subject: [PATCH] new chat messages don't force chat window to bottom if it was scrolled up --- static/anonkunQM.js | 5 ++++- static/anonkunUser.js | 5 ++++- todo | 2 +- 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/static/anonkunQM.js b/static/anonkunQM.js index d368d7f..146a717 100644 --- a/static/anonkunQM.js +++ b/static/anonkunQM.js @@ -18,7 +18,9 @@ var tid = setInterval( function () { let mbox = document.getElementById('chatWindow'); mbox.innerHTML = mbox.innerHTML + msg_str; - mbox.scrollTop = mbox.scrollHeight; + if ((mbox.scrollTop + mbox.offsetHeight) >= (mbox.scrollHeight - mbox.clientHeight / 2)) { + mbox.scrollTop = mbox.scrollHeight; + } }); socket.on('new_post', function(data) { deactivate_post(); @@ -143,6 +145,7 @@ var tid = setInterval( function () { let text = mtarea.value.trim(); mtarea.value = ''; if (text == '') { return; } + document.getElementById('chatWindow').scrollTop = document.getElementById('chatWindow').scrollHeight; socket.emit('message', {message: text, name: 'Anonymous', room: room_id}); } }); diff --git a/static/anonkunUser.js b/static/anonkunUser.js index 813512e..803f3d4 100644 --- a/static/anonkunUser.js +++ b/static/anonkunUser.js @@ -18,7 +18,9 @@ var tid = setInterval( function () { let mbox = document.getElementById('chatWindow'); mbox.innerHTML = mbox.innerHTML + msg_str; - mbox.scrollTop = mbox.scrollHeight; + if ((mbox.scrollTop + mbox.offsetHeight) >= (mbox.scrollHeight - mbox.clientHeight / 2)) { + mbox.scrollTop = mbox.scrollHeight; + } }); socket.on('new_post', function(data) { deactivate_post(); @@ -129,6 +131,7 @@ var tid = setInterval( function () { let text = mtarea.value.trim(); mtarea.value = ''; if (text == '') { return; } + document.getElementById('chatWindow').scrollTop = document.getElementById('chatWindow').scrollHeight; socket.emit('message', {message: text, name: 'Anonymous', room: room_id}); } }); diff --git a/todo b/todo index 91f83a8..fa22a96 100644 --- a/todo +++ b/todo @@ -12,13 +12,13 @@ Enable namefagging Account managament/logout Display profile link in header bar Tagging system +Quote backlinks Improvements: Revamp post editing More options for text posts (lists and so on) More rigorous input checking in events.py New post displays chat message -New chat message doesn't take chat window to the bottom if it was scrolled up Record email on signup Change urls Poll vote highlights entire option