UNPKG

instantjob-recruiter-client

Version:

a set of tools for creating an instantjob recruiter react client

176 lines (147 loc) 5.04 kB
'use strict'; Object.defineProperty(exports, "__esModule", { value: true }); var _getPrototypeOf = require('babel-runtime/core-js/object/get-prototype-of'); var _getPrototypeOf2 = _interopRequireDefault(_getPrototypeOf); var _classCallCheck2 = require('babel-runtime/helpers/classCallCheck'); var _classCallCheck3 = _interopRequireDefault(_classCallCheck2); var _createClass2 = require('babel-runtime/helpers/createClass'); var _createClass3 = _interopRequireDefault(_createClass2); var _possibleConstructorReturn2 = require('babel-runtime/helpers/possibleConstructorReturn'); var _possibleConstructorReturn3 = _interopRequireDefault(_possibleConstructorReturn2); var _inherits2 = require('babel-runtime/helpers/inherits'); var _inherits3 = _interopRequireDefault(_inherits2); var _react = require('react'); var _react2 = _interopRequireDefault(_react); var _reactDom = require('react-dom'); var _reactDom2 = _interopRequireDefault(_reactDom); var _reactInfinite = require('react-infinite'); var _reactInfinite2 = _interopRequireDefault(_reactInfinite); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } // import {List, AutoSizer} from 'react-virtualized' // import auto_bind from 'common/auto_bind' var InfiniteList = function (_Component) { (0, _inherits3.default)(InfiniteList, _Component); function InfiniteList(props) { (0, _classCallCheck3.default)(this, InfiniteList); var _this = (0, _possibleConstructorReturn3.default)(this, (InfiniteList.__proto__ || (0, _getPrototypeOf2.default)(InfiniteList)).call(this, props)); _this.state = { height: 100 }; _this.update_dimensions = _this.update_dimensions.bind(_this); _this.get_scroll_top = _this.get_scroll_top.bind(_this); _this.scroll_to = _this.scroll_to.bind(_this); _this.infinite_dom = null; return _this; } (0, _createClass3.default)(InfiniteList, [{ key: 'componentDidMount', value: function componentDidMount() { this.update_dimensions(); $(window).resize(this.update_dimensions); this.infinite_dom = _reactDom2.default.findDOMNode(this.infinite_list); } }, { key: 'componentWillUnmount', value: function componentWillUnmount() { $(window).off("resize", this.update_dimensions); } }, { key: 'componentDidUpdate', value: function componentDidUpdate() { this.update_dimensions(); } }, { key: 'update_dimensions', value: function update_dimensions() { var height = $(this.wrapper).height(); if (height !== this.state.height) { this.setState({ height: height }); } } }, { key: 'scroll_to', value: function scroll_to(index) { this.infinite_dom.scrollTop = index; } }, { key: 'get_scroll_top', value: function get_scroll_top() { return this.infinite_dom.scrollTop; } }, { key: 'render', value: function render() { var _this2 = this; var _props = this.props, className = _props.className, item_height = _props.item_height, onInfiniteLoad = _props.onInfiniteLoad, isInfiniteLoading = _props.isInfiniteLoading, handle_scroll = _props.handle_scroll, children = _props.children; return _react2.default.createElement( 'div', { ref: function ref(wrapper) { return _this2.wrapper = wrapper; }, className: className, style: { flex: 1, overflow: 'hidden' } }, _react2.default.createElement( _reactInfinite2.default, { ref: function ref(infinite_list) { return _this2.infinite_list = infinite_list; }, containerHeight: this.state.height || 1, elementHeight: item_height, timeScrollStateLastsForAfterUserScrolls: 200, onInfiniteLoad: onInfiniteLoad, isInfiniteLoading: isInfiniteLoading, infiniteLoadBeginEdgeOffset: 200, handleScroll: handle_scroll }, children ) ); } }]); return InfiniteList; }(_react.Component); // // export default class BetterList extends Component { // constructor(props) { // super(props) // auto_bind(this) // } // // render_row({index, key, style}) { // const {children} = this.props // return ( // <div key={key} style={style}> // {children[index]} // </div> // ) // } // // render() { // const {children, item_height, className} = this.props // return ( // <AutoSizer> // {({height, width}) => ( // <List // className={className} // height={height} // width={width} // rowCount={children.length} // rowHeight={item_height || 50} // rowRenderer={this.render_row} // /> // )} // </AutoSizer> // ) // } // } InfiniteList.defaultProps = { item_height: 50 }; exports.default = InfiniteList;