React Scroll Utils

Questions? Ask in Slack #vcc-ui

@volvo-cars/react-scroll-utils

@volvo-cars/react-scroll-utils@volvo-cars/react-scroll-utils@volvo-cars/react-scroll-utils

This package exposes useful utility hooks that can be used to help you with user scrolling concerns.

Installation

$ yarn add @volvo-cars/react-scroll-utils

💡 This package includes Typescript definitions


useElementHasScrolled

Returns an array with both a ref and hasScrolled element.

NameDescriptionTypeDefault Value
disabledIf true, hook does not refresh dimensions. Will report the current scroll status if set to false after user has already scrolled.booleanfalse
offsetThresholdUse to delay returning true for hasScrolled until the user has scrolled by that amountnumber0

Examples

A demonstration implementation can be found in the vcc-ui Storybook.

2024 © Volvo Car Corporation