1.3.24 • Published 2 years ago

usegetdistance v1.3.24

Weekly downloads
-
License
ISC
Repository
github
Last release
2 years ago

useGetDistance

React Hook to perfomatically calculate distances of a given HTML element at every scroll.

Installation and usage:

npm i -D usegetdistance

Importing package:

import useGetDistance from 'usegetdistance'

Usage:

useGetDistance(elementId, ({currentTranslate}) => {} )

Provide an elementId for the hook to calculate its distance to the top of the user's window at every scroll
with document.getElementById('element-id').

Write your callback function that uses the currentTranslate.getElementToTop value provided by the hook.
The currentTranslate.getElementToTop (type: number) value is the provided element's distance to the top
of the user's screen.

Example:

import useGetDistance from 'usegetdistance';

const elementId = document.getElementById('container-id')

useGetDistance(elementId, ({ currentTranslate }) => {
   console.log(currentTranslate.elementToTop)
});
1.3.24

2 years ago

1.3.23

2 years ago

1.3.22

2 years ago

1.3.21

2 years ago

1.3.2

2 years ago

1.3.12

2 years ago

1.3.11

2 years ago

1.3.1

2 years ago

1.3.0

2 years ago

1.2.28

2 years ago

1.2.27

2 years ago

1.2.25

2 years ago

1.2.24

2 years ago

1.2.23

2 years ago

1.2.22

2 years ago

1.2.21

2 years ago

1.2.2

2 years ago

1.2.16

2 years ago

1.2.15

2 years ago

1.2.14

2 years ago

1.2.13

2 years ago

1.2.12

2 years ago

1.2.11

2 years ago

1.2.1

2 years ago

1.1.15

2 years ago

1.1.14

2 years ago

1.1.13

2 years ago

1.1.12

2 years ago

1.1.11

2 years ago

1.1.10

2 years ago

1.1.9

2 years ago

1.1.8

2 years ago

1.1.7

2 years ago

1.1.6

2 years ago

1.1.5

2 years ago

1.1.4

2 years ago

1.1.2

2 years ago

1.1.1

2 years ago

1.1.0

2 years ago

1.0.0

2 years ago