clauderic / react-tiny-virtual-list

A tiny but mighty 3kb list virtualization library, with zero dependencies 💪 Supports variable heights/widths, sticky items, scrolling to index, and more!
https://clauderic.github.io/react-tiny-virtual-list/
MIT License
2.46k stars 166 forks source link

Add support for sticky items #55

Closed clauderic closed 6 years ago

clauderic commented 6 years ago

This PR adds a stickyIndices prop to add support for sticky headers:

The prop accepts an array of indices that should be made sticky (eg, stickyIndices={[0, 20, 50, 100]})

The solution relies on position: sticky, so it will only work in browsers that support that feature, but will degrade gracefully for other browsers.

It also works with horizontal lists:

How to test locally

Clone the project and check out this branch. Run yarn followed by npm start.

To-do

codecov[bot] commented 6 years ago

Codecov Report

Merging #55 into master will increase coverage by 0.12%. The diff coverage is 100%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master      #55      +/-   ##
==========================================
+ Coverage   94.16%   94.28%   +0.12%     
==========================================
  Files           3        3              
  Lines         137      140       +3     
  Branches       17       17              
==========================================
+ Hits          129      132       +3     
  Misses          8        8
Impacted Files Coverage Δ
src/index.tsx 100% <100%> (ø) :arrow_up:
src/constants.ts 100% <100%> (ø) :arrow_up:

Continue to review full report at Codecov.

Legend - Click here to learn more Δ = absolute <relative> (impact), ø = not affected, ? = missing data Powered by Codecov. Last update 6d3e8a3...e881d57. Read the comment docs.

jeroenransijn commented 6 years ago

Would be awesome to get this PR in, let me know if I can help at all.

jeroenransijn commented 6 years ago

@clauderic do you need any help getting this over the finish line? I would love to move this in the Evergreen component library.

jeroenransijn commented 6 years ago

👍 Thanks @clauderic!