content: import React from 'react'
  import styles from './scroll.css'
  
  class Scroll extends React.Component {
      state = {
          isShown: false
      }
      componentDidMount () {
          document.addEventListener('scroll', () => {
              this.handleScroll();
          })
      }
      handleScroll()  {
          if (!this.state.isShown) {
              if (window.scrollY > 300) {
                  this.setState({
                      isShown: true
                  });
              }
          }
          else {
              if (window.scrollY < 100) {
                  this.setState({
                      isShown: false
                  })
              }
          }
      }
  
  handleClick () {
      let distance = window.scrollY;
      let id;
      if (distance < 100) {
          if (id) {
              clearInterval(id);
          }
          window.scrollTo(0,0);
      }
      else {
          id = setInterval(function() {
              if (window.scrollY < 100) {
                  clearInterval(id);
                  window.scrollTo(0,0);
              }
              else {
                  console.log(window.scrollY)
                  window.scrollTo(0, distance/5);
              }
          }, 1);
      }
  }
    render() {
        let scrollClassName = 'banScroll';
        let isShown = this.state.isShown;
        if (isShown) {
            scrollClassName = 'scroll';
        }
        return (
            <div className={styles[scrollClassName]} onClick={this.handleClick}>
              <a href="#">Top</a>          
              </div>);
    }
  }
  
  export default Scroll
  