import React from 'react';
import PropTypes from 'prop-types';
import detectPassiveEvents from 'detect-passive-events';
-import scrollTop from '../scroll';
+import { scrollTop } from '../scroll';
export default class Column extends React.PureComponent {
import ColumnHeader from './column_header';
import PropTypes from 'prop-types';
import { debounce } from 'lodash';
-import scrollTop from '../../../scroll';
+import { scrollTop } from '../../../scroll';
import { isMobile } from '../../../is_mobile';
export default class Column extends React.PureComponent {
import BundleColumnError from './bundle_column_error';
import { Compose, Notifications, HomeTimeline, CommunityTimeline, PublicTimeline, HashtagTimeline, FavouritedStatuses } from '../../ui/util/async-components';
+import { scrollRight } from '../../../scroll';
+
const componentMap = {
'COMPOSE': Compose,
'HOME': HomeTimeline,
this.setState({ shouldAnimate: true });
}
- componentDidUpdate() {
+ componentDidUpdate(prevProps) {
this.lastIndex = getIndex(this.context.router.history.location.pathname);
this.setState({ shouldAnimate: true });
+
+ if (this.props.children !== prevProps.children) {
+ scrollRight(this.node);
+ }
}
handleSwipe = (index) => {
}
}
+ setRef = (node) => {
+ this.node = node;
+ }
+
renderView = (link, index) => {
const columnIndex = getIndex(this.context.router.history.location.pathname);
const title = this.props.intl.formatMessage({ id: link.props['data-preview-title-id'] });
}
return (
- <div className='columns-area'>
+ <div className='columns-area' ref={this.setRef}>
{columns.map(column => {
const params = column.get('params', null) === null ? null : column.get('params').toJS();
const easingOutQuint = (x, t, b, c, d) => c * ((t = t / d - 1) * t * t * t * t + 1) + b;
-const scrollTop = (node) => {
+const scroll = (node, key, target) => {
const startTime = Date.now();
- const offset = node.scrollTop;
- const targetY = -offset;
+ const offset = node[key];
+ const gap = target - offset;
const duration = 1000;
let interrupt = false;
return;
}
- node.scrollTop = easingOutQuint(0, elapsed, offset, targetY, duration);
+ node[key] = easingOutQuint(0, elapsed, offset, gap, duration);
requestAnimationFrame(step);
};
};
};
-export default scrollTop;
+export const scrollRight = (node) => scroll(node, 'scrollLeft', node.scrollWidth);
+export const scrollTop = (node) => scroll(node, 'scrollTop', 0);