clean up frontend
This commit is contained in:
17
app/modifiers/chat-scroll-bottom.js
Normal file
17
app/modifiers/chat-scroll-bottom.js
Normal file
@@ -0,0 +1,17 @@
|
||||
import Modifier from 'ember-modifier';
|
||||
|
||||
// Keeps the chat scrolled to the bottom: on insert, when another
|
||||
// conversation is opened, and when the number of messages changes. The same
|
||||
// conversation and count (e.g. a poll reload) leaves the scroll position
|
||||
// alone, so reading history is not interrupted.
|
||||
export default class ChatScrollBottom extends Modifier {
|
||||
lastKey = null;
|
||||
|
||||
modify(element, positional) {
|
||||
const [id, count] = positional;
|
||||
const key = `${id}:${count}`;
|
||||
if (key === this.lastKey) return;
|
||||
this.lastKey = key;
|
||||
element.scrollTop = element.scrollHeight;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user