title: React scrollTo / get Y position of an element/component
body: <p>The following piece of code scrolls to top and also accepts a delay:</p>
  
  <pre><code>const ScrollToTop = React.createClass({
    getInitialState: function () {
      return {intervalId: 0};
    },
  
    scrollStep: function () {
      const top = 0;
  
      if (window.pageYOffset === top) {
        clearInterval(this.state.intervalId);
      }
      window.scroll(top, window.pageYOffset - this.props.scrollStepInPx);
    },
  
    scrollToTop: function (event) {
      event.preventDefault();
  
      const intervalId = setInterval(this.scrollStep, this.props.delayInMs);
  
      this.setState({intervalId: intervalId});
    }
  });
  </code></pre>
  
  <p>How can I achieve something similar but using my main navigation? Is there a way of calculating the element's offset? I could then instead of passing <strong>top</strong> pass <strong>this</strong>.</p>