From b92d0107a9021c5e9416a2de4e2d91a9ad35e958 Mon Sep 17 00:00:00 2001 From: lars285 Date: Mon, 24 Jun 2024 08:42:32 +0200 Subject: [PATCH] Fixed scroll to top --- react-app/app/page.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/react-app/app/page.js b/react-app/app/page.js index 1f95175..83c1b8e 100644 --- a/react-app/app/page.js +++ b/react-app/app/page.js @@ -29,7 +29,7 @@ export default function Home() { window.addEventListener('scroll', onScroll, { passive: true }); return () => window.removeEventListener('scroll', onScroll); }, []); - + async function getData() { setLoading(true); const resKisten = await fetch(apiURL + '/chests'); @@ -188,15 +188,15 @@ export default function Home() { color: 'white', }} onClick={() => { - if(window.innerHeight + window.scrollY >= document.body.scrollHeight - 10) { + if(window.innerHeight + window.scrollY>= document.body.scrollHeight - 70) { window.scrollTo(0, 0); } else { window.scrollTo(0, document.body.scrollHeight); } }} > - - {window.innerHeight + offset >= document.body.scrollHeight - 10 ? "Scroll To Top" : "Scroll To End"} + + {(document.body.scrollHeight - 70 >= window.innerHeight + offset || offset == 0) ? "Scroll To End" : "Scroll To Top"}