question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

If VirtualScroll is wrapped inside AutoSize dragging an item doesn't trigger scroll

See original GitHub issue

Awesome job @clauderic 👍

I’m having a huge list that I’m using react-virtualized but if I want the width to be dynamic, for this I must wrap it with AutoSize You should already know this 😊

class VirtualList extends Component {
  render() {
    const { items } = this.props;

    return (
      <AutoSizer disableHeight>
        {({ width }) => (
          <VirtualScroll
            ref="VirtualScroll"
            estimatedRowSize={70}
            rowHeight={70}
            rowRenderer={({ index }) => {
              const { product } = items[index];
              return <SortableItem index={index} product={product} />;
            }}
            rowCount={items.length}
            width={width}
            height={500}
          />
        )}
      </AutoSizer>
    );
  }
}

So when I do, I lose the ability to scroll while dragging & item, any hints how to fix this?

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:6 (3 by maintainers)

github_iconTop GitHub Comments

8reactions
ahmedelgabricommented, Jun 10, 2016

Managed to solve it by wrapping the <Sortablelist> itself with <AutoSizer/> and passing the width to the <VirtualScroll />

<AutoSizer disableHeight>
  {({ width }) => (
    <SortableList ref="SortableList" items={items} width={width} onSortEnd={this.onSortEnd} />
  )}
</AutoSizer>
class VirtualList extends Component {
  render() {
    const { items, width } = this.props;

    return (
          <VirtualScroll
            ref="VirtualScroll"
            estimatedRowSize={70}
            rowHeight={70}
            rowRenderer={({ index }) => {
              const { product } = items[index];
              return <SortableItem index={index} product={product} />;
            }}
            rowCount={items.length}
            width={width}
            height={500}
          />
    );
  }
}
1reaction
mitchellwarrcommented, Jan 30, 2019

Thank you for this Issue thread, it fixed my issue. I suggest adding this to the docs somewhere as I only found this fix thanks to Google after reading through the docs and examples.

Read more comments on GitHub >

github_iconTop Results From Across the Web

virtual-scroll: support items of unknown size #10113 - GitHub
Support virtual scrolling over a list of items whose size is not known and needs to be measured.
Read more >
Cdk virtual scrolling issue - angular - Stack Overflow
I had a situation where the virtual scroll's viewport was in a flex-box, so it needed to respond to what the flex's layout...
Read more >
overscroll-behavior - CSS: Cascading Style Sheets | MDN
The overscroll-behavior CSS property sets what a browser does when reaching the boundary of a scrolling area.
Read more >
NGrid: Strategies
And a special vScrollNone strategy which disable virtual scrolling. You can ... When the height of the rows are not equal, using fixed...
Read more >
Scrolling | Angular Material
Virtual scrolling is different from strategies like infinite scroll where it renders a set amount of elements and then when you hit the...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found