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:
parent
ec01d33b50
commit
db5e7fd6b6
9 changed files with 75 additions and 54 deletions
|
@ -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();
|
||||
}
|
||||
});
|
||||
})();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue