-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathscroll.js
More file actions
24 lines (21 loc) · 922 Bytes
/
scroll.js
File metadata and controls
24 lines (21 loc) · 922 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
eventManager.on('ChatDetected', function override() {
globalSet('scroll', function (room, force=false) {
if (!force) return this.super(room);
debug('Forcing scroll');
const container = $(`#${room} .chat-messages`);
container.scrollTop(container.prop('scrollHeight'));
});
function scrollToBottom(room) {
global('scroll')(room, true);
}
// Force scrolling to bottom after loading history -- do last
eventManager.on(':ready', eventManager.on('Chat:getHistory', ({room}) => scrollToBottom(room)));
// See if we should scroll this message
let force = false;
eventManager.on('preChat:getMessage', function ({room}) {
if (this.canceled) return;
const container = $(`#${room} .chat-messages`);
force = container.scrollTop() + 100 > container.prop('scrollHeight') - container.height();
});
eventManager.on('Chat:getMessage', ({room}) => force && scrollToBottom(room));
});