Skip to content

Commit

Permalink
Added methods on ChatWindow to interface with scroll plugin
Browse files Browse the repository at this point in the history
  • Loading branch information
Voiture-0 committed Nov 15, 2024
1 parent 31695ae commit 7a843f4
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
4 changes: 2 additions & 2 deletions assets/chat/js/chat.js
Original file line number Diff line number Diff line change
Expand Up @@ -437,11 +437,11 @@ class Chat {
// ESC
document.addEventListener('keydown', (e) => {
if (isKeyCode(e, KEYCODES.ESC)) {
const activeView = this.getActiveWindow().scrollplugin;
const activeWindow = this.getActiveWindow();
// If any menus are open, close them first
if (this.getActiveMenu()) ChatMenu.closeMenus(this);
// If the active window is scrolled up (not pinned), scroll to bottom
else if (!activeView.pinned) activeView.scrollBottom();
else if (!activeWindow.isScrollPinned()) activeWindow.scrollBottom();
}
});

Expand Down
8 changes: 8 additions & 0 deletions assets/chat/js/window.js
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,14 @@ class ChatWindow extends EventEmitter {
}
}

isScrollPinned() {
return this.scrollplugin.pinned;
}

scrollBottom() {
this.scrollplugin.scrollBottom();
}

/**
* Use chat state (settings and authentication data) to update the messages in
* this window.
Expand Down

0 comments on commit 7a843f4

Please sign in to comment.