BosNaufal / react-scrollbar

The Simplest Scroll Area Component with custom scrollbar for React JS. https://bosnaufal.github.io/react-scrollbar
MIT License
71 stars 30 forks source link

example for using scrollToY #9

Closed lc00 closed 7 years ago

lc00 commented 7 years ago

Hiii,

I am having trouble to figure out how to apply the scrollToY() method. Could you please add a more detailed example or add into your current usage example on how to use scrollToY() method please?

Thanks!

BosNaufal commented 7 years ago

Hi @lc00, Thank you for giving me an issue~

I think the usage of scrollToY() method is well explained in documentation. But I will give you full example for sure.

import React from 'react';
import ReactDOM from 'react-dom';

import ReactScrollbar from 'react-scrollbar-js';

class App extends React.Component {

  render(){
    return(
      <ReactScrollbar className="my-scrollbar" speed={ 100 } ref="Scrollbar">
        <div className="should-have-a-children scroll-me">
          <p>And Now</p>
          <p>You Can Put</p>
          <p>A Long Content Here</p>
        </div>
      </ReactScrollbar>
    )
  }

  // Examples
  someMethod() {
    this.refs.Scrollbar.scrollToY(100)
  }

}

ReactDOM.render(<App />, document.getElementById("app"))
lc00 commented 7 years ago

Thanks!