1

I can't find how to know if one windowed component is scrolled to bottom in here. Is there a property telling where is the scroll relative to the overflowed parent?

Thanks!

David Casanellas
  • 815
  • 2
  • 11
  • 18

1 Answers1

2

From you question I'm assuming you are using the component from the link given.
If so I would add a wrapper div with an onScroll listener to it like so:

const Row = ({ index, style }) => (
  <div className={index % 2 ? "ListItemOdd" : "ListItemEven"} style={style}>
    Row {index}
  </div>
);

class Example extends Component {
  scrollCheck = event => {
    const bottom = event.target.scrollHeight - event.target.scrollTop === event.target.clientHeight;
    if (bottom) {
      console.log("At The Bottom"); //Add in what you want here
    }
  };

  render() {
    return (
      <Fragment>
        <div onScroll={this.scrollCheck}>
          <List
            className="List"
            height={150}
            itemCount={1000}
            itemSize={35}
            ref={this.listRef}
            width={300}
            id="myDiv"
          >
            {Row}
          </List>
        </div>
      </Fragment>
    );
  }
}

Your question is very similar to here so maybe check that out too.

Mick Vader
  • 100
  • 9
  • 1
    Property 'scrollHeight' does not exist on type 'EventTarget'.ts(2339) – Jason G Feb 17 '20 at 20:09
  • 1
    @JasonG Maybe try ```Element.scrollHeight``` as per this documentation: https://developer.mozilla.org/en-US/docs/Web/API/Element/scrollHeight – Mick Vader Feb 18 '20 at 10:24