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
|
@ -32,7 +32,7 @@
|
|||
|
||||
<div class='discussion-container'></div>
|
||||
|
||||
<div class="bottom-bar">
|
||||
<div class="bottom-bar" id='footer'>
|
||||
<form class='send'>
|
||||
<div class='attachments'>
|
||||
<div class='paperclip'></div>
|
||||
|
|
|
@ -42,6 +42,7 @@
|
|||
if (this.model.id) {
|
||||
this.model.fetchMessages({reset: true});
|
||||
}
|
||||
window.addEventListener('resize', this.view.resize.bind(this.view));
|
||||
},
|
||||
|
||||
events: {
|
||||
|
|
|
@ -45,6 +45,7 @@
|
|||
this.conversations.get(message.conversationId).fetchMessages();
|
||||
}.bind(this));
|
||||
}.bind(this));
|
||||
window.addEventListener('resize', this.inbox.resize.bind(this.inbox));
|
||||
},
|
||||
events: {
|
||||
'keyup': 'keyup',
|
||||
|
|
|
@ -43,6 +43,18 @@ var Whisper = Whisper || {};
|
|||
addAll: function() {
|
||||
this.$el.html('');
|
||||
this.collection.each(this.addOne, this);
|
||||
this.resize();
|
||||
},
|
||||
|
||||
resize: function() {
|
||||
var height = window.innerHeight - $('#header').height() - $('#footer').height();
|
||||
if (this.$el.height() > height) {
|
||||
this.$el.css('height', height + 'px');
|
||||
this.$el.css('overflow-y', 'scroll');
|
||||
} else {
|
||||
this.$el.css('height', 'auto');
|
||||
this.$el.css('overflow-y', 'auto');
|
||||
}
|
||||
}
|
||||
});
|
||||
})();
|
||||
|
|
|
@ -33,6 +33,6 @@ var Whisper = Whisper || {};
|
|||
addAll: function() {
|
||||
Whisper.ListView.prototype.addAll.apply(this, arguments); // super()
|
||||
this.scrollToBottom();
|
||||
},
|
||||
}
|
||||
});
|
||||
})();
|
||||
|
|
|
@ -66,10 +66,11 @@ button {
|
|||
|
||||
|
||||
.message-list {
|
||||
margin: 36px + 16px 0;
|
||||
padding: 0;
|
||||
max-height: 100%;
|
||||
margin: 0;
|
||||
padding: 1em 0;
|
||||
list-style: none;
|
||||
font-weight: 300;
|
||||
overflow-y: scroll;
|
||||
|
||||
li {
|
||||
margin: 0 8px 16px;
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
* {
|
||||
box-sizing: border-box;
|
||||
max-height: 100%;
|
||||
}
|
||||
|
||||
body {
|
||||
|
|
|
@ -2,6 +2,10 @@
|
|||
margin-top: 36px;
|
||||
}
|
||||
|
||||
#contacts {
|
||||
overflow-y: scroll;
|
||||
}
|
||||
|
||||
.loading .gutter {
|
||||
// TODO: spinner
|
||||
}
|
||||
|
|
|
@ -3,8 +3,7 @@
|
|||
font-family: 'Roboto';
|
||||
src: url("/fonts/Roboto-Regular.ttf") format("truetype"); }
|
||||
* {
|
||||
box-sizing: border-box;
|
||||
max-height: 100%; }
|
||||
box-sizing: border-box; }
|
||||
|
||||
body {
|
||||
height: 100%;
|
||||
|
@ -26,6 +25,9 @@ body {
|
|||
.gutter {
|
||||
margin-top: 36px; }
|
||||
|
||||
#contacts {
|
||||
overflow-y: scroll; }
|
||||
|
||||
.contact .checkbox {
|
||||
display: none; }
|
||||
|
||||
|
@ -194,10 +196,11 @@ button {
|
|||
content: "✓"; }
|
||||
|
||||
.message-list {
|
||||
margin: 52px 0;
|
||||
padding: 0;
|
||||
max-height: 100%;
|
||||
margin: 0;
|
||||
padding: 1em 0;
|
||||
list-style: none;
|
||||
font-weight: 300; }
|
||||
overflow-y: scroll; }
|
||||
.message-list li {
|
||||
margin: 0 8px 16px; }
|
||||
.message-list li::after {
|
||||
|
|
Loading…
Reference in a new issue