Skip to content

Conversation

zombieJ
Copy link
Member

@zombieJ zombieJ commented Jul 10, 2019

We use class component here since typescript can not support generic in function component

Virtual list display logic:

  1. scroll / initialize trigger measure
  2. Get location item of current scrollTop
  3. [Render] Render visible items
  4. Get all the visible items height
  5. [Render] Update top item margin-top to fit the position

Algorithm

We split scroll bar into equal slice. An item with whatever height occupy the same range slice.
When scrollTop change, it will calculate the item percentage position and move item to the position.
Then calculate other item position base on the located item.

Concept

located item

The base position item which other items position calculate base on.

@zombieJ zombieJ requested a review from afc163 July 10, 2019 06:16
@vercel
Copy link

vercel bot commented Jul 10, 2019

This pull request is automatically deployed with Now.
To access deployments, click Details below or on the icon next to each push.

Latest deployment for this branch: https://rc-virtual-list-git-animation.react-component.now.sh

@codecov
Copy link

codecov bot commented Jul 10, 2019

Codecov Report

Merging #2 into master will increase coverage by 14.6%.
The diff coverage is 16.33%.

Impacted file tree graph

@@            Coverage Diff            @@
##           master      #2      +/-   ##
=========================================
+ Coverage       0%   14.6%   +14.6%     
=========================================
  Files           3       4       +1     
  Lines          71     226     +155     
  Branches       12      46      +34     
=========================================
+ Hits            0      33      +33     
- Misses         71     192     +121     
- Partials        0       1       +1
Impacted Files Coverage Δ
src/Filler.tsx 0% <0%> (ø) ⬆️
src/utils/itemUtil.ts 0% <0%> (ø)
src/List.tsx 0% <0%> (ø) ⬆️
src/utils/algorithmUtil.ts 94.28% <94.28%> (ø)

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 bf9d7ef...61574d7. Read the comment docs.

@vercel vercel bot temporarily deployed to staging July 11, 2019 07:30 Inactive
@vercel vercel bot temporarily deployed to staging July 11, 2019 07:31 Inactive
@zombieJ
Copy link
Member Author

zombieJ commented Jul 11, 2019

@zombieJ zombieJ marked this pull request as ready for review July 13, 2019 03:07
@zombieJ zombieJ merged commit 5407ff8 into master Jul 13, 2019
@delete-merged-branch delete-merged-branch bot deleted the animation branch July 13, 2019 03:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant