diff --git a/mail.js b/mail.js index 11f6144..d5c1d5b 100644 --- a/mail.js +++ b/mail.js @@ -1041,20 +1041,34 @@ var MessageList = React.createClass({ if (i > 0 && scrollTop < p+30) firstVisible = 0; else - firstVisible = Math.floor((scrollTop - (i > 0 ? 30 : 0))/itemH); + firstVisible = Math.floor((scrollTop - p - (i > 0 ? 30 : 0))/itemH); } if (lastVisibleGrp === undefined && scrollTop+scrollSize < top) { lastVisibleGrp = i; - if (i > 0 && scrollTop < p+30) + if (i > 0 && scrollTop+scrollSize < p+30) lastVisible = 0; else - lastVisible = Math.floor((scrollTop+scrollSize+itemH-1 - (i > 0 ? 30 : 0))/itemH); + lastVisible = Math.floor((scrollTop+scrollSize - p - (i > 0 ? 30 : 0))/itemH); + if (lastVisible >= this.state.groups[i].messageCount) + lastVisible = this.state.groups[i].messageCount-1; } if (firstVisibleGrp !== undefined && lastVisibleGrp !== undefined) break; } - this.setState({ firstDayTop: scrollTop, firstDay: this.state.groups[firstVisibleGrp].name }); + if (lastVisibleGrp === undefined) + { + lastVisibleGrp = this.state.groups.length-1; + lastVisible = this.state.groups[lastVisibleGrp].messageCount-1; + } + this.setState({ + firstDayTop: scrollTop, + firstDay: this.state.groups[firstVisibleGrp].name, + firstGrp: firstVisibleGrp, + firstMsg: firstVisible, + lastGrp: lastVisibleGrp, + lastMsg: lastVisible + }); }, deleteSelected: function() { @@ -1114,10 +1128,19 @@ var MessageList = React.createClass({ { return this.refs.title.offsetHeight; }, + getMessages: function(grp, start, end) + { + var a = grp.messages.slice(start, end); + for (var i = 0; i < end-start; i++) + if (!a[i]) + a[i] = null; + return a; + }, render: function() { var self = this; var total = 0; + var itemH = (Store.layout == 'message-on-right' ? 60 : 30); return