Fossil SCM
chat: the 'New message...' toast now includes a button which scrolls to the bottom of the message area.
Commit
e85b679d99619a0120a41f9b6b58475c7e31c8a696b1db200530dbb85b084279
Parent
b1d44f9ea713a6d…
1 file changed
+8
-4
+8
-4
| --- src/chat.js | ||
| +++ src/chat.js | ||
| @@ -252,11 +252,15 @@ | ||
| 252 | 252 | : false)){ |
| 253 | 253 | /* If a new non-history message arrives while the user is |
| 254 | 254 | scrolled elsewhere, do not scroll to the latest |
| 255 | 255 | message, but gently alert the user that a new message |
| 256 | 256 | has arrived. */ |
| 257 | - F.toast.message("New message has arrived."); | |
| 257 | + if(!f.btnDown){ | |
| 258 | + f.btnDown = D.button("⇣⇣⇣"); | |
| 259 | + f.btnDown.addEventListener('click',()=>this.scrollMessagesTo(1),false); | |
| 260 | + } | |
| 261 | + F.toast.message(f.btnDown," New message has arrived."); | |
| 258 | 262 | }else if(!this._isBatchLoading && e.dataset.xfrom===Chat.me){ |
| 259 | 263 | this.scheduleScrollOfMsg(e); |
| 260 | 264 | }else if(!this._isBatchLoading){ |
| 261 | 265 | /* When a message from someone else arrives, we have to |
| 262 | 266 | figure out whether or not to scroll it into view. Ideally |
| @@ -320,11 +324,11 @@ | ||
| 320 | 324 | } |
| 321 | 325 | ForceResizeKludge(); |
| 322 | 326 | return this; |
| 323 | 327 | }, |
| 324 | 328 | /** Tries to scroll the message area to... |
| 325 | - <0 = top of the message list, >1 = bottom of the message list, | |
| 329 | + <0 = top of the message list, >0 = bottom of the message list, | |
| 326 | 330 | 0 == the newest message (normally the same position as >1). |
| 327 | 331 | */ |
| 328 | 332 | scrollMessagesTo: function(where){ |
| 329 | 333 | if(where<0){ |
| 330 | 334 | Chat.e.messagesWrapper.scrollTop = 0; |
| @@ -1008,16 +1012,16 @@ | ||
| 1008 | 1012 | return rect.top - popupSize.height -2; |
| 1009 | 1013 | }; |
| 1010 | 1014 | })()/*#chat-settings-button setup*/; |
| 1011 | 1015 | |
| 1012 | 1016 | (function(){ /* buttons to scroll to the begin/end of the messages. */ |
| 1013 | - E1('#chat-scroll-bottom').addEventListener('click',function(ev){ | |
| 1017 | + Chat.e.btnMsgEnd.addEventListener('click',function(ev){ | |
| 1014 | 1018 | ev.preventDefault(); |
| 1015 | 1019 | Chat.scrollMessagesTo(1); |
| 1016 | 1020 | return false; |
| 1017 | 1021 | }); |
| 1018 | - E1('#chat-scroll-top').addEventListener('click',function(ev){ | |
| 1022 | + Chat.e.btnMsgHome.addEventListener('click',function(ev){ | |
| 1019 | 1023 | ev.preventDefault(); |
| 1020 | 1024 | Chat.scrollMessagesTo(-1); |
| 1021 | 1025 | return false; |
| 1022 | 1026 | }); |
| 1023 | 1027 | })(); |
| 1024 | 1028 |
| --- src/chat.js | |
| +++ src/chat.js | |
| @@ -252,11 +252,15 @@ | |
| 252 | : false)){ |
| 253 | /* If a new non-history message arrives while the user is |
| 254 | scrolled elsewhere, do not scroll to the latest |
| 255 | message, but gently alert the user that a new message |
| 256 | has arrived. */ |
| 257 | F.toast.message("New message has arrived."); |
| 258 | }else if(!this._isBatchLoading && e.dataset.xfrom===Chat.me){ |
| 259 | this.scheduleScrollOfMsg(e); |
| 260 | }else if(!this._isBatchLoading){ |
| 261 | /* When a message from someone else arrives, we have to |
| 262 | figure out whether or not to scroll it into view. Ideally |
| @@ -320,11 +324,11 @@ | |
| 320 | } |
| 321 | ForceResizeKludge(); |
| 322 | return this; |
| 323 | }, |
| 324 | /** Tries to scroll the message area to... |
| 325 | <0 = top of the message list, >1 = bottom of the message list, |
| 326 | 0 == the newest message (normally the same position as >1). |
| 327 | */ |
| 328 | scrollMessagesTo: function(where){ |
| 329 | if(where<0){ |
| 330 | Chat.e.messagesWrapper.scrollTop = 0; |
| @@ -1008,16 +1012,16 @@ | |
| 1008 | return rect.top - popupSize.height -2; |
| 1009 | }; |
| 1010 | })()/*#chat-settings-button setup*/; |
| 1011 | |
| 1012 | (function(){ /* buttons to scroll to the begin/end of the messages. */ |
| 1013 | E1('#chat-scroll-bottom').addEventListener('click',function(ev){ |
| 1014 | ev.preventDefault(); |
| 1015 | Chat.scrollMessagesTo(1); |
| 1016 | return false; |
| 1017 | }); |
| 1018 | E1('#chat-scroll-top').addEventListener('click',function(ev){ |
| 1019 | ev.preventDefault(); |
| 1020 | Chat.scrollMessagesTo(-1); |
| 1021 | return false; |
| 1022 | }); |
| 1023 | })(); |
| 1024 |
| --- src/chat.js | |
| +++ src/chat.js | |
| @@ -252,11 +252,15 @@ | |
| 252 | : false)){ |
| 253 | /* If a new non-history message arrives while the user is |
| 254 | scrolled elsewhere, do not scroll to the latest |
| 255 | message, but gently alert the user that a new message |
| 256 | has arrived. */ |
| 257 | if(!f.btnDown){ |
| 258 | f.btnDown = D.button("⇣⇣⇣"); |
| 259 | f.btnDown.addEventListener('click',()=>this.scrollMessagesTo(1),false); |
| 260 | } |
| 261 | F.toast.message(f.btnDown," New message has arrived."); |
| 262 | }else if(!this._isBatchLoading && e.dataset.xfrom===Chat.me){ |
| 263 | this.scheduleScrollOfMsg(e); |
| 264 | }else if(!this._isBatchLoading){ |
| 265 | /* When a message from someone else arrives, we have to |
| 266 | figure out whether or not to scroll it into view. Ideally |
| @@ -320,11 +324,11 @@ | |
| 324 | } |
| 325 | ForceResizeKludge(); |
| 326 | return this; |
| 327 | }, |
| 328 | /** Tries to scroll the message area to... |
| 329 | <0 = top of the message list, >0 = bottom of the message list, |
| 330 | 0 == the newest message (normally the same position as >1). |
| 331 | */ |
| 332 | scrollMessagesTo: function(where){ |
| 333 | if(where<0){ |
| 334 | Chat.e.messagesWrapper.scrollTop = 0; |
| @@ -1008,16 +1012,16 @@ | |
| 1012 | return rect.top - popupSize.height -2; |
| 1013 | }; |
| 1014 | })()/*#chat-settings-button setup*/; |
| 1015 | |
| 1016 | (function(){ /* buttons to scroll to the begin/end of the messages. */ |
| 1017 | Chat.e.btnMsgEnd.addEventListener('click',function(ev){ |
| 1018 | ev.preventDefault(); |
| 1019 | Chat.scrollMessagesTo(1); |
| 1020 | return false; |
| 1021 | }); |
| 1022 | Chat.e.btnMsgHome.addEventListener('click',function(ev){ |
| 1023 | ev.preventDefault(); |
| 1024 | Chat.scrollMessagesTo(-1); |
| 1025 | return false; |
| 1026 | }); |
| 1027 | })(); |
| 1028 |