Skip to content

Commit

Permalink
Fixed scroll to top
Browse files Browse the repository at this point in the history
  • Loading branch information
lars285 committed Jun 24, 2024
1 parent ea60b72 commit b92d010
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions react-app/app/page.js
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down Expand Up @@ -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"}
</button>
</div>
</div>
Expand Down

0 comments on commit b92d010

Please sign in to comment.