fix: later scroll button

This commit is contained in:
Jannis Mattheis 2025-08-03 22:11:17 +02:00
parent 85d10bfa40
commit 6ced902d93
1 changed files with 2 additions and 2 deletions

View File

@ -6,8 +6,8 @@ const ScrollUpButton = () => {
const [state, setState] = React.useState({display: 'none', opacity: 0});
React.useEffect(() => {
const scrollHandler = () => {
const currentScrollPos = window.pageYOffset;
const opacity = Math.min(currentScrollPos / 500, 1);
const currentScrollPos = Math.max(window.pageYOffset - 1000, 0);
const opacity = Math.min(currentScrollPos / 1000, 1);
const nextState = {display: currentScrollPos > 0 ? 'inherit' : 'none', opacity};
if (state.display !== nextState.display || state.opacity !== nextState.opacity) {
setState(nextState);