Fossil SCM

chat: the 'New message...' toast now includes a button which scrolls to the bottom of the message area.

stephan 2021-01-04 14:15 trunk
Commit e85b679d99619a0120a41f9b6b58475c7e31c8a696b1db200530dbb85b084279
1 file changed +8 -4
+8 -4
--- src/chat.js
+++ src/chat.js
@@ -252,11 +252,15 @@
252252
: false)){
253253
/* If a new non-history message arrives while the user is
254254
scrolled elsewhere, do not scroll to the latest
255255
message, but gently alert the user that a new message
256256
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.");
258262
}else if(!this._isBatchLoading && e.dataset.xfrom===Chat.me){
259263
this.scheduleScrollOfMsg(e);
260264
}else if(!this._isBatchLoading){
261265
/* When a message from someone else arrives, we have to
262266
figure out whether or not to scroll it into view. Ideally
@@ -320,11 +324,11 @@
320324
}
321325
ForceResizeKludge();
322326
return this;
323327
},
324328
/** 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,
326330
0 == the newest message (normally the same position as >1).
327331
*/
328332
scrollMessagesTo: function(where){
329333
if(where<0){
330334
Chat.e.messagesWrapper.scrollTop = 0;
@@ -1008,16 +1012,16 @@
10081012
return rect.top - popupSize.height -2;
10091013
};
10101014
})()/*#chat-settings-button setup*/;
10111015
10121016
(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){
10141018
ev.preventDefault();
10151019
Chat.scrollMessagesTo(1);
10161020
return false;
10171021
});
1018
- E1('#chat-scroll-top').addEventListener('click',function(ev){
1022
+ Chat.e.btnMsgHome.addEventListener('click',function(ev){
10191023
ev.preventDefault();
10201024
Chat.scrollMessagesTo(-1);
10211025
return false;
10221026
});
10231027
})();
10241028
--- 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

Keyboard Shortcuts

Open search /
Next entry (timeline) j
Previous entry (timeline) k
Open focused entry Enter
Show this help ?
Toggle theme Top nav button