Delay center scroll when sidebar opens to be after animation

Этот коммит содержится в:
JoramWilander
2015-12-09 08:53:53 -05:00
родитель 0b960e4a0b
Коммит 984dc19f30

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

@@ -7,6 +7,8 @@ import SearchStore from '../stores/search_store.jsx';
import PostStore from '../stores/post_store.jsx'; import PostStore from '../stores/post_store.jsx';
import * as Utils from '../utils/utils.jsx'; import * as Utils from '../utils/utils.jsx';
const SIDEBAR_SCROLL_DELAY = 500;
export default class SidebarRight extends React.Component { export default class SidebarRight extends React.Component {
constructor(props) { constructor(props) {
super(props); super(props);
@@ -39,8 +41,13 @@ export default class SidebarRight extends React.Component {
PostStore.removeSelectedPostChangeListener(this.onSelectedChange); PostStore.removeSelectedPostChangeListener(this.onSelectedChange);
SearchStore.removeShowSearchListener(this.onShowSearch); SearchStore.removeShowSearchListener(this.onShowSearch);
} }
componentWillUpdate() { componentWillUpdate(nextProps, nextState) {
PostStore.jumpPostsViewSidebarOpen(); const isOpen = this.state.search_visible || this.state.post_right_visible;
const willOpen = nextState.search_visible || nextState.post_right_visible;
if (!isOpen && willOpen) {
setTimeout(() => PostStore.jumpPostsViewSidebarOpen(), SIDEBAR_SCROLL_DELAY);
}
} }
doStrangeThings() { doStrangeThings() {
// We should have a better way to do this stuff // We should have a better way to do this stuff