Better comments, and correct bottom header sticky calc to allow clicking

This commit is contained in:
wmwragg 2016-08-28 19:18:41 +01:00
parent 123d9b56c8
commit 2b1ed707c4

View file

@ -323,6 +323,8 @@ module.exports = React.createClass({
// Use the offset of the top of the scroll area from the window // Use the offset of the top of the scroll area from the window
// as this is used to calculate the CSS fixed top position for the stickies // as this is used to calculate the CSS fixed top position for the stickies
var scrollAreaOffset = scrollArea.getBoundingClientRect().top; var scrollAreaOffset = scrollArea.getBoundingClientRect().top;
// Use the offset of the top of the componet from the window
// as this is used to calculate the CSS fixed top position for the stickies
var scrollAreaHeight = ReactDOM.findDOMNode(this).getBoundingClientRect().height; var scrollAreaHeight = ReactDOM.findDOMNode(this).getBoundingClientRect().height;
if (initialise) { if (initialise) {
@ -352,7 +354,8 @@ module.exports = React.createClass({
var self = this; var self = this;
var scrollStuckOffset = 0; var scrollStuckOffset = 0;
// Scroll to the passed in position // Scroll to the passed in position, i.e. a header was clicked and in a scroll to state
// rather than a collapsable one (see RoomSubList.isCollapsableOnClick method for details)
if (scrollToPosition !== undefined) { if (scrollToPosition !== undefined) {
scrollArea.scrollTop = scrollToPosition; scrollArea.scrollTop = scrollToPosition;
} }
@ -373,7 +376,7 @@ module.exports = React.createClass({
if (scrollToPosition !== undefined && stickyPosition === scrollToPosition) { if (scrollToPosition !== undefined && stickyPosition === scrollToPosition) {
scrollStuckOffset = topStuckHeight; scrollStuckOffset = topStuckHeight;
} }
} else if (self.scrollAreaSufficient && stickyPosition >= ((scrollArea.scrollTop + scrollAreaHeight) - bottomStuckHeight)) { } else if (self.scrollAreaSufficient && stickyPosition > ((scrollArea.scrollTop + scrollAreaHeight) - bottomStuckHeight)) {
/// Bottom stickies /// Bottom stickies
sticky.dataset.stuck = "bottom"; sticky.dataset.stuck = "bottom";
stickyHeader.classList.add("mx_RoomSubList_fixed"); stickyHeader.classList.add("mx_RoomSubList_fixed");