Created
April 16, 2020 20:46
-
-
Save LishuGupta652/643c3bb83d1c784c167891f734c102ff to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import * as React from "react"; | |
import { useScrollData } from "scroll-data-hook"; | |
const Scroll = () => { | |
const { | |
scrolling, | |
time, | |
speed, | |
direction, | |
position, | |
relativeDistance, | |
totalDistance | |
} = useScrollData({ | |
onScrollStart: () => { | |
console.log("Started scrolling"); | |
}, | |
onScrollEnd: () => { | |
console.log("Finished scrolling"); | |
} | |
}); | |
return ( | |
<div> | |
<p>{scrolling ? "Scrolling" : "Not scrolling"}</p> | |
<p>Scrolling time: {time} milliseconds</p> | |
<p>Horizontal speed: {speed.x} pixels per second</p> | |
<p>Vertical speed: {speed.y} pixels per second</p> | |
<p> | |
Direction: {direction.x} {direction.y} | |
</p> | |
<p> | |
Relative distance: {relativeDistance.x}/{relativeDistance.y} | |
</p> | |
<p> | |
Total distance: {totalDistance.x}/{totalDistance.y} | |
</p> | |
</div> | |
); | |
}; | |
export default Scroll; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment