2017-06-04 08:39:38 +09:00
|
|
|
import React from 'react';
|
|
|
|
import PropTypes from 'prop-types';
|
|
|
|
import scrollTop from '../scroll';
|
|
|
|
|
2017-06-24 02:36:54 +09:00
|
|
|
export default class Column extends React.PureComponent {
|
2017-06-04 08:39:38 +09:00
|
|
|
|
|
|
|
static propTypes = {
|
|
|
|
children: PropTypes.node,
|
|
|
|
};
|
|
|
|
|
|
|
|
scrollTop () {
|
|
|
|
const scrollable = this.node.querySelector('.scrollable');
|
|
|
|
|
|
|
|
if (!scrollable) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
this._interruptScrollAnimation = scrollTop(scrollable);
|
|
|
|
}
|
|
|
|
|
|
|
|
handleWheel = () => {
|
|
|
|
if (typeof this._interruptScrollAnimation !== 'function') {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
this._interruptScrollAnimation();
|
|
|
|
}
|
|
|
|
|
|
|
|
setRef = c => {
|
|
|
|
this.node = c;
|
|
|
|
}
|
|
|
|
|
|
|
|
render () {
|
|
|
|
const { children } = this.props;
|
|
|
|
|
|
|
|
return (
|
2017-07-22 03:33:16 +09:00
|
|
|
<div
|
|
|
|
role='region'
|
|
|
|
className='column'
|
|
|
|
ref={this.setRef}
|
|
|
|
onWheel={this.handleWheel}
|
|
|
|
>
|
2017-06-04 08:39:38 +09:00
|
|
|
{children}
|
|
|
|
</div>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|