diff --git a/src/component-index.js b/src/component-index.js index 63d2f3c39d..869d60f204 100644 --- a/src/component-index.js +++ b/src/component-index.js @@ -89,6 +89,7 @@ module.exports.components['views.rooms.RoomTile'] = require('./components/views/ module.exports.components['views.rooms.SearchableEntityList'] = require('./components/views/rooms/SearchableEntityList'); module.exports.components['views.rooms.SearchResultTile'] = require('./components/views/rooms/SearchResultTile'); module.exports.components['views.rooms.TabCompleteBar'] = require('./components/views/rooms/TabCompleteBar'); +module.exports.components['views.rooms.TopUnreadMessagesBar'] = require('./components/views/rooms/TopUnreadMessagesBar'); module.exports.components['views.rooms.UserTile'] = require('./components/views/rooms/UserTile'); module.exports.components['views.settings.ChangeAvatar'] = require('./components/views/settings/ChangeAvatar'); module.exports.components['views.settings.ChangeDisplayName'] = require('./components/views/settings/ChangeDisplayName'); diff --git a/src/components/structures/MessagePanel.js b/src/components/structures/MessagePanel.js index cfa4735481..d3d60c2af5 100644 --- a/src/components/structures/MessagePanel.js +++ b/src/components/structures/MessagePanel.js @@ -15,6 +15,7 @@ limitations under the License. */ var React = require('react'); +var ReactDOM = require("react-dom"); var sdk = require('../../index'); /* (almost) stateless UI component which builds the event tiles in the room timeline. @@ -35,6 +36,9 @@ module.exports = React.createClass({ // event after which we should show a read marker readMarkerEventId: React.PropTypes.string, + // whether the read marker should be visible + readMarkerVisible: React.PropTypes.bool, + // the userid of our user. This is used to suppress the read marker // for pending messages. ourUserId: React.PropTypes.string, @@ -91,6 +95,34 @@ module.exports = React.createClass({ return this.refs.scrollPanel.getScrollState(); }, + // returns one of: + // + // null: there is no read marker + // -1: read marker is above the window + // 0: read marker is within the window + // +1: read marker is below the window + getReadMarkerPosition: function() { + var readMarker = this.refs.readMarkerNode; + var messageWrapper = this.refs.scrollPanel; + + if (!readMarker || !messageWrapper) { + return null; + } + + var wrapperRect = ReactDOM.findDOMNode(messageWrapper).getBoundingClientRect(); + var readMarkerRect = readMarker.getBoundingClientRect(); + + // the read-marker pretends to have zero height when it is actually + // two pixels high; +2 here to account for that. + if (readMarkerRect.bottom + 2 < wrapperRect.top) { + return -1; + } else if (readMarkerRect.top < wrapperRect.bottom) { + return 0; + } else { + return 1; + } + }, + /* jump to the bottom of the content. */ scrollToBottom: function() { @@ -103,7 +135,7 @@ module.exports = React.createClass({ * * pixelOffset gives the number of pixels between the bottom of the node * and the bottom of the container. If undefined, it will put the node - * in the middle of the container. + * 1/3 of the way down of the container. */ scrollToEvent: function(eventId, pixelOffset) { if (this.refs.scrollPanel) { @@ -166,15 +198,17 @@ module.exports = React.createClass({ ret.push(