useWindowScroll*

React sensor hook that re-renders on window scroll.

hooks
x: 0
y: 0

Variants

with useHooks

useWindowScroll

0

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

26

27

28

29

30

31

32

33

34

35

36

37

38

39

40

41

42

43

44

45

46

47

48

49

The useWindowScroll hook is useful for tracking and manipulating the scroll position of a web page within a React component. It allows you to easily access the current scroll coordinates (x and y) through the “state” object returned by the hook. Additionally, the hook provides a “scrollTo” function that can be used to programmatically scroll to a specific position on the page. This hook is helpful when building components that require dynamic behavior based on the scroll position, such as lazy-loading content, infinite scrolling, or implementing smooth scrolling animations.

Installation

Run the following command:

npx ever-ui-clx@0.2.1 add demo-use-window-scroll
# └──> Hook coming soon.

Usage