1
0
mirror of https://github.com/moparisthebest/kaiwa synced 2024-08-13 17:03:51 -04:00

Fix chat scrolling

This commit is contained in:
Lance Stout 2013-12-19 15:34:29 -08:00
parent 2ce7e90cbd
commit 22128dfa66
10 changed files with 30 additions and 47 deletions

View File

@ -2,20 +2,11 @@
"use strict"; "use strict";
var _ = require('underscore'); var _ = require('underscore');
var raf = require('raf-component');
module.exports = { module.exports = {
initializeScroll: function () { initializeScroll: function () {
var check = _.bind(_.throttle(this.handleScroll, 100), this);
var self = this; var self = this;
function animate() {
self.rafID = raf(animate);
check();
}
animate();
this.pinnedToBottom = true; this.pinnedToBottom = true;
this.lastScrollTop = 0; this.lastScrollTop = 0;
}, },
@ -29,7 +20,6 @@ module.exports = {
scrollPageUnload: function () { scrollPageUnload: function () {
this.savePosition(); this.savePosition();
this.trimOldChats(); this.trimOldChats();
raf.cancel(this.rafID);
}, },
savePosition: function () { savePosition: function () {
this.lastScrollPosition = this.pinnedToBottom ? '' : this.$scrollContainer.scrollTop(); this.lastScrollPosition = this.pinnedToBottom ? '' : this.$scrollContainer.scrollTop();
@ -46,7 +36,7 @@ module.exports = {
}, 500); }, 500);
} }
}, },
handleScroll: function (e) { handleScroll: _.debounce(function (e) {
var scrollTop = this.$scrollContainer[0].scrollTop; var scrollTop = this.$scrollContainer[0].scrollTop;
var direction = scrollTop >= this.lastScrollTop ? 'down' : 'up'; var direction = scrollTop >= this.lastScrollTop ? 'down' : 'up';
if (direction === 'up' && !this.isBottom()) { if (direction === 'up' && !this.isBottom()) {
@ -55,7 +45,7 @@ module.exports = {
this.handleAtBottom(); this.handleAtBottom();
} }
this.lastScrollTop = scrollTop; this.lastScrollTop = scrollTop;
}, }, 500),
scrollIfPinned: function (animate) { scrollIfPinned: function (animate) {
if (this.pinnedToBottom) this.scrollToBottom(animate); if (this.pinnedToBottom) this.scrollToBottom(animate);
}, },

View File

@ -39,7 +39,7 @@ module.exports = BasePage.extend(chatHelpers).extend({
formattedTZO: 'header .tzo' formattedTZO: 'header .tzo'
}, },
classBindings: { classBindings: {
onCall: '.conversation' onCall: '.messages'
}, },
show: function (animation) { show: function (animation) {
BasePage.prototype.show.apply(this, [animation]); BasePage.prototype.show.apply(this, [animation]);

View File

@ -129,7 +129,7 @@ exports.includes.mucListItem = function anonymous(locals) {
exports.includes.mucWrappedMessage = function anonymous(locals) { exports.includes.mucWrappedMessage = function anonymous(locals) {
var buf = []; var buf = [];
with (locals || {}) { with (locals || {}) {
buf.push('<li><div class="sender"><div class="name">' + jade.escape(null == (jade.interp = message.from.resource) ? "" : jade.interp) + '</div><a href="#" class="messageAvatar"><!--img(src=message.sender.avatar, alt=message.sender.displayName, data-placement="below")--></a></div><div class="messageWrapper"><div' + jade.attrs({ buf.push('<li><div class="sender"><div class="name">' + jade.escape(null == (jade.interp = message.from.resource) ? "" : jade.interp) + '</div></div><div class="messageWrapper"><div' + jade.attrs({
id: "chat" + message.cid, id: "chat" + message.cid,
"class": "message" + " " + message.classList "class": "message" + " " + message.classList
}, { }, {

View File

@ -1,7 +1,5 @@
li li
.sender .sender
.name=message.from.resource .name=message.from.resource
a.messageAvatar(href='#')
//img(src=message.sender.avatar, alt=message.sender.displayName, data-placement="below")
.messageWrapper .messageWrapper
include mucBareMessage include mucBareMessage

View File

@ -22,8 +22,7 @@
"human-view": "1.2.0", "human-view": "1.2.0",
"templatizer": "0.1.2", "templatizer": "0.1.2",
"underscore": "1.5.1", "underscore": "1.5.1",
"raf-component": "1.1.1", "stanza.io": "2.9.3",
"stanza.io": "2.9.2",
"notify.js": "0.0.3", "notify.js": "0.0.3",
"wildemitter": "0.0.5", "wildemitter": "0.0.5",
"attachmediastream": "1.0.1", "attachmediastream": "1.0.1",

View File

@ -31,8 +31,3 @@ a
left: 201px left: 201px
height: 100% height: 100%
borderbox() borderbox()
.scroll-container
height: 100%
overflow-y: auto
-webkit-overflow-scrolling: touch

View File

@ -198,11 +198,6 @@ a:active {
-webkit-box-sizing: border-box; -webkit-box-sizing: border-box;
box-sizing: border-box; box-sizing: border-box;
} }
#pages .scroll-container {
height: 100%;
overflow-y: auto;
-webkit-overflow-scrolling: touch;
}
input[type=text], input[type=text],
input[type=email], input[type=email],
input[type=password], input[type=password],
@ -869,9 +864,10 @@ button.secondary:hover:not(:disabled) {
-moz-box-sizing: border-box; -moz-box-sizing: border-box;
-webkit-box-sizing: border-box; -webkit-box-sizing: border-box;
box-sizing: border-box; box-sizing: border-box;
overflow-y: auto;
overflow-x: hidden;
} }
.conversation { .conversation {
position: relative;
bottom: 0px; bottom: 0px;
left: 0px; left: 0px;
right: 0px; right: 0px;
@ -995,16 +991,18 @@ button.secondary:hover:not(:disabled) {
.messages { .messages {
margin: 0px; margin: 0px;
padding: 0px; padding: 0px;
padding-top: 130px;
overflow-y: auto; overflow-y: auto;
overflow-x: hidden; overflow-x: hidden;
position: relative; position: absolute;
bottom: 75px; top: 0px;
bottom: 0px;
padding-top: 55px;
padding-bottom: 55px;
width: 100%; width: 100%;
display: table;
-moz-box-sizing: border-box; -moz-box-sizing: border-box;
-webkit-box-sizing: border-box; -webkit-box-sizing: border-box;
box-sizing: border-box; box-sizing: border-box;
-webkit-overflow-scrolling: touch;
} }
.messages li { .messages li {
position: relative; position: relative;
@ -1048,19 +1046,20 @@ button.secondary:hover:not(:disabled) {
color: #565656; color: #565656;
padding: 5px; padding: 5px;
text-align: right; text-align: right;
background-color: #f7f7f7; border-top: 1px solid #eee;
border-top: 1px solid #e1e1e1;
white-space: nowrap; white-space: nowrap;
vertical-align: middle;
} }
.messages .sender .name { .messages .sender .name {
padding-left: 10px; padding-left: 10px;
vertical-align: middle;
} }
.messages .messageWrapper { .messages .messageWrapper {
display: table-cell; display: table-cell;
padding: 5px; padding: 5px;
border-top: 1px solid #eee; border-top: 1px solid #eee;
width: 99%; width: 99%;
vertical-align: top; vertical-align: middle;
} }
.messages .message { .messages .message {
font-size: 12px; font-size: 12px;
@ -1260,7 +1259,6 @@ button.secondary:hover:not(:disabled) {
} }
} }
#wrapper { #wrapper {
position: relative !important;
transition: all 1s; transition: all 1s;
} }
#calls { #calls {

View File

@ -4,7 +4,6 @@
$callHeight = 80px $callHeight = 80px
#wrapper #wrapper
position: relative !important
transition: all 1s transition: all 1s
//&.hasActiveCall //&.hasActiveCall

View File

@ -4,9 +4,10 @@
.page.chat .page.chat
padding-top: 0px padding-top: 0px
borderbox() borderbox()
overflow-y: auto
overflow-x: hidden
.conversation .conversation
position: relative
bottom: 0px bottom: 0px
left: 0px left: 0px
right: 0px right: 0px
@ -115,14 +116,16 @@
.messages .messages
margin: 0px margin: 0px
padding: 0px padding: 0px
padding-top: 130px
overflow-y: auto overflow-y: auto
overflow-x: hidden overflow-x: hidden
position: relative position: absolute
bottom: 75px top: 0px
bottom: 0px
padding-top: 55px
padding-bottom: 55px
width: 100% width: 100%
display: table
borderbox() borderbox()
-webkit-overflow-scrolling: touch
li li
position: relative position: relative
@ -157,19 +160,20 @@
color: $gray color: $gray
padding: 5px padding: 5px
text-align: right text-align: right
background-color: #f7f7f7 border-top: 1px solid #eee
border-top: 1px solid #e1e1e1
white-space: nowrap white-space: nowrap
vertical-align: middle
.name .name
padding-left: 10px padding-left: 10px
vertical-align: middle
.messageWrapper .messageWrapper
display: table-cell display: table-cell
padding: 5px padding: 5px
border-top: 1px solid #eee border-top: 1px solid #eee
width: 99% width: 99%
vertical-align: top vertical-align: middle
.message .message
font-size: $font-size-small font-size: $font-size-small

View File

@ -1,5 +1,5 @@
CACHE MANIFEST CACHE MANIFEST
# 0.0.1 1387474672583 # 0.0.1 1387496053745
CACHE: CACHE:
/app.js /app.js