/**
 * Created by baoyinghai on 4/18/17.
 */
import React from 'react';

export default class Link extends React.Component {

  constructor(props) {
    super(props);
    this.linkClick = this.linkClick.bind(this);
  }

  linkClick(e) {
    e.preventDefault();
    if (window.scrollTo) {
      window.scrollTo({ behavior: 'smooth', top: this.props.offsetTop });
    }
  }

  render() {
    return (
      <li onClick={this.linkClick}>
        <span title={this.props.title}>{this.props.title}</span>
      </li>
    );
  }
}
