From b4eb83d66ff3304653bfc80a1b2f4982351eae73 Mon Sep 17 00:00:00 2001 From: hmhealey Date: Wed, 16 Dec 2015 09:30:46 -0500 Subject: Added scroll to bottom arrows for mobile --- web/react/components/posts_view.jsx | 27 ++++++++++++++++++++++++--- web/sass-files/sass/partials/_post.scss | 18 ++++++++++++++++++ web/static/images/postArrows.png | Bin 0 -> 5684 bytes 3 files changed, 42 insertions(+), 3 deletions(-) create mode 100644 web/static/images/postArrows.png diff --git a/web/react/components/posts_view.jsx b/web/react/components/posts_view.jsx index a4dd51e19..aedf431af 100644 --- a/web/react/components/posts_view.jsx +++ b/web/react/components/posts_view.jsx @@ -23,6 +23,7 @@ export default class PostsView extends React.Component { this.createPosts = this.createPosts.bind(this); this.updateScrolling = this.updateScrolling.bind(this); this.handleResize = this.handleResize.bind(this); + this.scrollToBottom = this.scrollToBottom.bind(this); this.jumpToPostNode = null; this.wasAtBottom = true; @@ -283,9 +284,7 @@ export default class PostsView extends React.Component { } updateScrolling() { if (this.props.scrollType === PostsView.SCROLL_TYPE_BOTTOM) { - window.requestAnimationFrame(() => { - this.refs.postlist.scrollTop = this.refs.postlist.scrollHeight; - }); + this.scrollToBottom(); } else if (this.props.scrollType === PostsView.SCROLL_TYPE_NEW_MESSAGE) { window.requestAnimationFrame(() => { // If separator exists scroll to it. Otherwise scroll to bottom. @@ -335,6 +334,11 @@ export default class PostsView extends React.Component { handleResize() { this.updateScrolling(); } + scrollToBottom() { + window.requestAnimationFrame(() => { + this.refs.postlist.scrollTop = this.refs.postlist.scrollHeight; + }); + } componentDidMount() { if (this.props.postList != null) { this.updateScrolling(); @@ -460,9 +464,26 @@ export default class PostsView extends React.Component { ); } + let scrollToBottomArrows = null; + if ($(window).width() <= 768) { + let scrollToBottomArrowsClass = 'post-list__arrows'; + if (this.state.isScrolling && !this.wasAtBottom) { + scrollToBottomArrowsClass += ' scrolling'; + } + + scrollToBottomArrows = ( +
+ ); + } + return (
{floatingTimestamp} + {scrollToBottomArrows}