Fix list view scrolling

Resize handlers are ugly. But not as ugly as scroll handlers. :p
Normalized some whitespace along the way.
This commit is contained in:
lilia 2015-01-29 20:59:08 -10:00
parent ec01d33b50
commit db5e7fd6b6
9 changed files with 75 additions and 54 deletions

View file

@ -16,23 +16,23 @@
var Whisper = Whisper || {};
(function () {
'use strict';
'use strict';
Whisper.MessageListView = Whisper.ListView.extend({
tagName: 'ul',
className: 'message-list',
itemView: Whisper.MessageView,
events: {
'add': 'scrollToBottom',
'update *': 'scrollToBottom'
},
scrollToBottom: function() {
// TODO: Avoid scrolling if user has manually scrolled up?
this.$el.scrollTop(this.el.scrollHeight);
},
addAll: function() {
Whisper.ListView.prototype.addAll.apply(this, arguments); // super()
this.scrollToBottom();
},
});
Whisper.MessageListView = Whisper.ListView.extend({
tagName: 'ul',
className: 'message-list',
itemView: Whisper.MessageView,
events: {
'add': 'scrollToBottom',
'update *': 'scrollToBottom'
},
scrollToBottom: function() {
// TODO: Avoid scrolling if user has manually scrolled up?
this.$el.scrollTop(this.el.scrollHeight);
},
addAll: function() {
Whisper.ListView.prototype.addAll.apply(this, arguments); // super()
this.scrollToBottom();
}
});
})();