This is created by Next.js with tailwind.
This is a interaction view page. The section of the page will be animated by how deep scroll is in. Not imediately completed when viewport is in the section like as other many of web pages with interaction.
- Detect the viewport is in a section.
- Measure the scroll percent from start point(0%) to end point(100%) with threshold value.
- Make interaction in some point of measured percent you want.
ContentsWrapper
: It's wrapper component for letting children component stick in viewport.
useScrollProgress
: It's for calculating the percent by how deep scroll is in and threshold value. And handling scroll event listner.
getWeightByProgress
: It's for calculating the value that you can use at interaction value(e.g: opacity value of css) by the percent range you want.
You can check out the demo page at this link
This project is licensed under the terms of the MIT license.