Advertisement
Guest User

Untitled

a guest
Oct 28th, 2016
55
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.53 KB | None | 0 0
  1. import Ember from 'ember';
  2.  
  3. export default Ember.Component.extend({
  4.  
  5. classNames: 'chat-box',
  6. sticky: true,
  7.  
  8. willUpdate() {
  9. this._super(...arguments);
  10.  
  11. let box = this.$('ul')[0];
  12. let isScrolledToBottom = box.scrollTop + box.clientHeight === box.scrollHeight;
  13. this.set('isScrolledToBottom', isScrolledToBottom);
  14. },
  15.  
  16. didRender() {
  17. this._super(...arguments);
  18.  
  19. if (this.get('isScrolledToBottom') && this.get('sticky')) {
  20. this.$('ul')[0].scrollTop = this.$('ul')[0].scrollHeight;
  21. }
  22. }
  23.  
  24. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement