forked from michaljaz/webmc
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathChat.js
More file actions
51 lines (44 loc) · 918 Bytes
/
Chat.js
File metadata and controls
51 lines (44 loc) · 918 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
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
// Generated by CoffeeScript 2.5.1
var Chat;
Chat = class Chat {
constructor(options) {
var _this;
_this = this;
this.FPC = options.FPC;
this.chatDiv = document.querySelector(".chat");
this.listen();
return;
}
listen() {
var _this;
_this = this;
window.addEventListener("wheel", function(e) {
if (_this.FPC.gameState !== "chat") {
e.preventDefault();
}
}, {
passive: false
});
return this;
}
isElementScrolledToBottom(el) {
if (el.scrollTop >= (el.scrollHeight - el.offsetHeight)) {
return true;
}
return false;
}
scrollToBottom(el) {
el.scrollTop = el.scrollHeight;
}
log(message) {
var atBottom;
atBottom = this.isElementScrolledToBottom(this.chatDiv);
$(".chat").append(message + "<br>");
if (atBottom) {
this.scrollToBottom(this.chatDiv);
}
}
};
export {
Chat
};