fisshy / react-scroll

React scroll component
https://github.com/fisshy/react-scroll/blob/master/README.md
MIT License
4.36k stars 438 forks source link

how do you scroll the body tag #180

Open craigcosmo opened 7 years ago

craigcosmo commented 7 years ago

I got a button, that when clicked, it activates scrollTop, the body tag will scroll to 3000px. Is there this component can help achieve that?

<button onclick={this.scrollNow.bind(this)}></button
fisshy commented 7 years ago

Yes.

craigcosmo commented 7 years ago

When you do scroll.scrollToTop(); how does the scroll understand that we want to scroll the tag?

fisshy commented 7 years ago

       <Link to="firstInsideContainer" containerId="containerElement">
          Go to first element inside container
        </Link>

        <Link to="secondInsideContainer" containerId="containerElement">
          Go to second element inside container
        </Link>
        <div className="element" id="containerElement">
          <Element name="firstInsideContainer">
            first element inside container
          </Element>

          <Element name="secondInsideContainer">
            second element inside container
          </Element>
        </div>