Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import Ember from 'ember';
- export default Ember.Component.extend({
- classNames: 'chat-box',
- sticky: true,
- willUpdate() {
- this._super(...arguments);
- let box = this.$('ul')[0];
- let isScrolledToBottom = box.scrollTop + box.clientHeight === box.scrollHeight;
- this.set('isScrolledToBottom', isScrolledToBottom);
- },
- didRender() {
- this._super(...arguments);
- if (this.get('isScrolledToBottom') && this.get('sticky')) {
- this.$('ul')[0].scrollTop = this.$('ul')[0].scrollHeight;
- }
- }
- });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement