1.3.24 • Published 4 years ago

usegetdistance v1.3.24

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

4 years ago

1.3.23

4 years ago

1.3.22

4 years ago

1.3.21

4 years ago

1.3.2

4 years ago

1.3.12

4 years ago

1.3.11

4 years ago

1.3.1

4 years ago

1.3.0

4 years ago

1.2.28

4 years ago

1.2.27

4 years ago

1.2.25

4 years ago

1.2.24

4 years ago

1.2.23

4 years ago

1.2.22

4 years ago

1.2.21

4 years ago

1.2.2

4 years ago

1.2.16

4 years ago

1.2.15

4 years ago

1.2.14

4 years ago

1.2.13

4 years ago

1.2.12

4 years ago

1.2.11

4 years ago

1.2.1

4 years ago

1.1.15

4 years ago

1.1.14

4 years ago

1.1.13

4 years ago

1.1.12

4 years ago

1.1.11

4 years ago

1.1.10

4 years ago

1.1.9

4 years ago

1.1.8

4 years ago

1.1.7

4 years ago

1.1.6

4 years ago

1.1.5

4 years ago

1.1.4

4 years ago

1.1.2

4 years ago

1.1.1

4 years ago

1.1.0

4 years ago

1.0.0

4 years ago