ilyashubin / scrollbooster

Enjoyable content drag-to-scroll library
https://ilyashubin.github.io/scrollbooster
MIT License
987 stars 81 forks source link

Detecting when the scrollable element is at the start or end of the scrollable viewport #21

Closed kfirba closed 4 years ago

kfirba commented 4 years ago

Hey!

We want to add navigation arrows on each side of the scrollable viewport that can also trigger scroll (by a predefined amount of pixels). When we reach the end or the start of the scrollable viewport, we would like to hide the corresponding arrow.

Taking a quick look at the code base, it seems like you are already calculating those metrics at applyBoundForce(). Do you think you can add those metrics to the getState method, thus making them available in the onUpdate() callback?

Thanks!

ilyashubin commented 4 years ago

Hello! Good idea. Added property borderCollision to state object https://github.com/ilyashubin/scrollbooster/releases/tag/v2.1.0