Flow for all the files

This commit is contained in:
Jori Lallo
2017-05-11 17:23:56 -07:00
parent a98199599a
commit 0a76d6af9e
110 changed files with 512 additions and 269 deletions

View File

@ -1,18 +1,21 @@
// @flow
import React from 'react';
import styles from '../DocumentEdit.scss';
import classNames from 'classnames/bind';
const cx = classNames.bind(styles);
class EditorPane extends React.Component {
static propTypes = {
children: React.PropTypes.node.isRequired,
onScroll: React.PropTypes.func.isRequired,
scrollTop: React.PropTypes.number,
fullWidth: React.PropTypes.bool,
};
type Props = {
children?: ?React.Element<any>,
onScroll?: Function,
scrollTop?: ?number,
fullWidth?: ?boolean,
};
componentWillReceiveProps = nextProps => {
class EditorPane extends React.Component {
props: Props;
componentWillReceiveProps = (nextProps: Props) => {
if (nextProps.scrollTop) {
this.scrollToPosition(nextProps.scrollTop);
}
@ -26,15 +29,16 @@ class EditorPane extends React.Component {
this.refs.pane.removeEventListener('scroll', this.handleScroll);
};
handleScroll = e => {
handleScroll = (e: Event) => {
setTimeout(() => {
const element = this.refs.pane;
const contentEl = this.refs.content;
this.props.onScroll(element.scrollTop / contentEl.offsetHeight);
this.props.onScroll &&
this.props.onScroll(element.scrollTop / contentEl.offsetHeight);
}, 50);
};
scrollToPosition = percentage => {
scrollToPosition = (percentage: number) => {
const contentEl = this.refs.content;
// Push to edges