Adding react scrollbar to the RHS thread (#2693)

* Adding scrollbar to the RHS thread

* Fixing the RHS thread scrolling issue
Этот коммит содержится в:
Asaad Mahmood
2016-04-13 17:33:42 +05:00
коммит произвёл Christopher Speller
родитель 76c4bebf9f
Коммит 51549cc0b2
6 изменённых файлов: 83 добавлений и 52 удалений

Просмотреть файл

@@ -203,7 +203,7 @@ class CreateComment extends React.Component {
draft.message = messageText; draft.message = messageText;
PostStore.storeCommentDraft(this.props.rootId, draft); PostStore.storeCommentDraft(this.props.rootId, draft);
$('.post-right__scroll').scrollTop($('.post-right__scroll')[0].scrollHeight); $('.post-right__scroll').parent().scrollTop($('.post-right__scroll')[0].scrollHeight);
this.setState({messageText: messageText}); this.setState({messageText: messageText});
} }
handleKeyDown(e) { handleKeyDown(e) {

Просмотреть файл

@@ -13,9 +13,26 @@ import RootPost from './rhs_root_post.jsx';
import Comment from './rhs_comment.jsx'; import Comment from './rhs_comment.jsx';
import Constants from 'utils/constants.jsx'; import Constants from 'utils/constants.jsx';
import FileUploadOverlay from './file_upload_overlay.jsx'; import FileUploadOverlay from './file_upload_overlay.jsx';
import Scrollbars from 'react-custom-scrollbars';
import React from 'react'; import React from 'react';
export function renderThumbHorizontal(props) {
return (
<div
{...props}
className='scrollbar--horizontal'
/>);
}
export function renderThumbVertical(props) {
return (
<div
{...props}
className='scrollbar--vertical'
/>);
}
export default class RhsThread extends React.Component { export default class RhsThread extends React.Component {
constructor(props) { constructor(props) {
super(props); super(props);
@@ -46,15 +63,11 @@ export default class RhsThread extends React.Component {
window.addEventListener('resize', this.handleResize); window.addEventListener('resize', this.handleResize);
this.mounted = true; this.mounted = true;
if (!Utils.isMobile()) {
$('.sidebar--right .post-right__scroll').perfectScrollbar();
}
} }
componentDidUpdate() { componentDidUpdate() {
if ($('.post-right__scroll')[0]) { if ($('.post-right__scroll')[0]) {
$('.post-right__scroll').scrollTop($('.post-right__scroll')[0].scrollHeight); $('.post-right__scroll').parent().scrollTop($('.post-right__scroll')[0].scrollHeight);
} }
$('.sidebar--right .post-right__scroll').perfectScrollbar('update');
this.resize(); this.resize();
} }
componentWillUnmount() { componentWillUnmount() {
@@ -109,7 +122,7 @@ export default class RhsThread extends React.Component {
this.setState({profiles}); this.setState({profiles});
} }
resize() { resize() {
$('.post-right__scroll').scrollTop(100000); $('.post-right__scroll').parent().scrollTop(100000);
} }
render() { render() {
const posts = this.state.posts; const posts = this.state.posts;
@@ -180,40 +193,48 @@ export default class RhsThread extends React.Component {
fromSearch={this.props.fromSearch} fromSearch={this.props.fromSearch}
isMentionSearch={this.props.isMentionSearch} isMentionSearch={this.props.isMentionSearch}
/> />
<div className='post-right__scroll'> <Scrollbars
<RootPost autoHide={true}
ref={selected.id} autoHideTimeout={500}
post={selected} autoHideDuration={500}
commentCount={postsArray.length} renderThumbHorizontal={renderThumbHorizontal}
user={profile} renderThumbVertical={renderThumbVertical}
currentUser={this.props.currentUser} >
/> <div className='post-right__scroll'>
<div className='post-right-comments-container'> <RootPost
{postsArray.map((comPost) => { ref={selected.id}
let p; post={selected}
if (UserStore.getCurrentId() === comPost.user_id) { commentCount={postsArray.length}
p = UserStore.getCurrentUser(); user={profile}
} else { currentUser={this.props.currentUser}
p = profiles[comPost.user_id];
}
return (
<Comment
ref={comPost.id}
key={comPost.id + 'commentKey'}
post={comPost}
user={p}
currentUser={this.props.currentUser}
/>
);
})}
</div>
<div className='post-create__container'>
<CreateComment
channelId={selected.channel_id}
rootId={selected.id}
/> />
<div className='post-right-comments-container'>
{postsArray.map((comPost) => {
let p;
if (UserStore.getCurrentId() === comPost.user_id) {
p = UserStore.getCurrentUser();
} else {
p = profiles[comPost.user_id];
}
return (
<Comment
ref={comPost.id}
key={comPost.id + 'commentKey'}
post={comPost}
user={p}
currentUser={this.props.currentUser}
/>
);
})}
</div>
<div className='post-create__container'>
<CreateComment
channelId={selected.channel_id}
rootId={selected.id}
/>
</div>
</div> </div>
</div> </Scrollbars>
</div> </div>
</div> </div>
); );

Просмотреть файл

@@ -22,6 +22,7 @@
"perfect-scrollbar": "0.6.10", "perfect-scrollbar": "0.6.10",
"react": "0.14.7", "react": "0.14.7",
"react-bootstrap": "0.28.3", "react-bootstrap": "0.28.3",
"react-custom-scrollbars": "^4.0.0-beta.1",
"react-dom": "0.14.7", "react-dom": "0.14.7",
"react-intl": "2.0.0-rc-1", "react-intl": "2.0.0-rc-1",
"react-router": "2.0.1", "react-router": "2.0.1",

Просмотреть файл

@@ -10,20 +10,22 @@
width: 100%; width: 100%;
z-index: 9999; z-index: 9999;
&__close { a {
color: $white; &.error-bar__close {
font-family: 'Open Sans', sans-serif;
font-size: 20px;
font-weight: 600;
padding: 0 10px;
position: absolute;
right: 0;
text-decoration: none;
top: 0;
&:hover {
color: $white; color: $white;
font-family: 'Open Sans', sans-serif;
font-size: 20px;
font-weight: 600;
padding: 0 10px;
position: absolute;
right: 0;
text-decoration: none; text-decoration: none;
top: 0;
&:hover {
color: $white;
text-decoration: none;
}
} }
} }
} }

Просмотреть файл

@@ -23,3 +23,9 @@ body {
scrollbar-shadow-color: #2D2C4D; scrollbar-shadow-color: #2D2C4D;
scrollbar-track-color: rgba(0, 0, 0, .1); scrollbar-track-color: rgba(0, 0, 0, .1);
} }
.scrollbar--horizontal,
.scrollbar--vertical {
@include border-radius(2px);
@include alpha-property(background-color, $black, .5);
}

Просмотреть файл

@@ -729,6 +729,7 @@ export function applyTheme(theme) {
changeCss('::-webkit-scrollbar-thumb', 'background:' + changeOpacity(theme.centerChannelColor, 0.4), 1); changeCss('::-webkit-scrollbar-thumb', 'background:' + changeOpacity(theme.centerChannelColor, 0.4), 1);
changeCss('body', 'scrollbar-arrow-color:' + theme.centerChannelColor, 4); changeCss('body', 'scrollbar-arrow-color:' + theme.centerChannelColor, 4);
changeCss('.app__body .modal .about-modal .about-modal__logo svg, .app__body .post .post__img svg', 'fill:' + theme.centerChannelColor, 1); changeCss('.app__body .modal .about-modal .about-modal__logo svg, .app__body .post .post__img svg', 'fill:' + theme.centerChannelColor, 1);
changeCss('.app__body .scrollbar--horizontal, .app__body .scrollbar--vertical', 'background:' + changeOpacity(theme.centerChannelColor, 0.5), 2);
} }
if (theme.newMessageSeparator) { if (theme.newMessageSeparator) {