1.3.24 • Published 3 years ago

usegetdistance v1.3.24

Weekly downloads
-
License
ISC
Repository
github
Last release
3 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

3 years ago

1.3.23

3 years ago

1.3.22

3 years ago

1.3.21

3 years ago

1.3.2

3 years ago

1.3.12

3 years ago

1.3.11

3 years ago

1.3.1

3 years ago

1.3.0

3 years ago

1.2.28

3 years ago

1.2.27

3 years ago

1.2.25

3 years ago

1.2.24

3 years ago

1.2.23

3 years ago

1.2.22

3 years ago

1.2.21

3 years ago

1.2.2

3 years ago

1.2.16

3 years ago

1.2.15

3 years ago

1.2.14

3 years ago

1.2.13

3 years ago

1.2.12

3 years ago

1.2.11

3 years ago

1.2.1

3 years ago

1.1.15

3 years ago

1.1.14

3 years ago

1.1.13

3 years ago

1.1.12

3 years ago

1.1.11

3 years ago

1.1.10

3 years ago

1.1.9

3 years ago

1.1.8

3 years ago

1.1.7

3 years ago

1.1.6

3 years ago

1.1.5

3 years ago

1.1.4

3 years ago

1.1.2

3 years ago

1.1.1

3 years ago

1.1.0

3 years ago

1.0.0

3 years ago