MCPcopy Create free account
hub / github.com/codebucks27/react-portfolio-final / handleScroll

Function handleScroll

src/subComponents/Anchor.jsx:39–57  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

37 useEffect(() => {
38
39 const handleScroll = () => {
40
41 let scrollPosition = window.pageYOffset;
42 let windowSize = window.innerHeight;
43 let bodyHeight = document.body.offsetHeight;
44
45 let diff = Math.max(bodyHeight - (scrollPosition + windowSize) )
46 //diff*100/scrollposition
47 let diffP = (diff * 100) / (bodyHeight - windowSize);
48
49 ref.current.style.transform = `translateY(${-diffP}%)`
50
51 if(window.pageYOffset > 5){
52 hiddenRef.current.style.display = 'none'
53 }else{
54 hiddenRef.current.style.display = 'block'
55
56 }
57 }
58
59 window.addEventListener('scroll', handleScroll)
60

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected