/*
 * Copyright (C) 2016 Actor LLC. <https://actor.im>
 */

import React, { Component, PropTypes } from 'react';
import classnames from 'classnames';
import SimpleScroll from 'simple-scrollbar';

class Scrollbar extends Component {
  static propTypes = {
    children: PropTypes.oneOfType([
      PropTypes.element,
      PropTypes.array
    ]),
    className: PropTypes.string,

    onScroll: PropTypes.func
  };

  constructor(props) {
    super(props);
    this.scrollbar = new SimpleScroll();
  }

  componentDidMount() {
    const scrollNode = React.findDOMNode(this.refs.scroll);
    this.scrollbar.initElement(scrollNode);
  }

  handleScroll = (event) => {
    const { onScroll } = this.props;
    onScroll && onScroll(event);
  };

  render() {
    const { children, className } = this.props;
    const wrapperClassName = classnames('scroll-wrapper', className);

    return (
      <div className={wrapperClassName} ref="scroll" onScroll={this.handleScroll}>
        {children}
      </div>
    );
  }
}

export default Scrollbar;

@@ -734,16 +734,150 @@
 ;%0A  %7D;%0A%0A
+  scrollTo = (to) =%3E %7B%0A    const scrollNode = React.findDOMNode(this.refs.scroll);%0A    this.scrollbar.scrollTo(scrollNode, to);%0A  %7D;%0A%0A
   render

add scrollTo method to scrollbar component