diff --git a/frontend/src/App.jsx b/frontend/src/App.jsx index 56fd27e..7901790 100644 --- a/frontend/src/App.jsx +++ b/frontend/src/App.jsx @@ -3220,18 +3220,33 @@ function ScrollToTop({ scrollRef }) { const [visible, setVisible] = useState(false); useEffect(() => { + // Prüfe sowohl window als auch den Ref-Container const el = scrollRef?.current; - if (!el) return; - const onScroll = () => setVisible(el.scrollTop > 300); - el.addEventListener('scroll', onScroll, { passive: true }); - return () => el.removeEventListener('scroll', onScroll); + + function check() { + const winScroll = window.scrollY || document.documentElement.scrollTop; + const elScroll = el ? el.scrollTop : 0; + setVisible(winScroll > 300 || elScroll > 300); + } + + window.addEventListener('scroll', check, { passive: true }); + if (el) el.addEventListener('scroll', check, { passive: true }); + return () => { + window.removeEventListener('scroll', check); + if (el) el.removeEventListener('scroll', check); + }; }, [scrollRef]); + function scrollUp() { + window.scrollTo({ top: 0, behavior: 'smooth' }); + if (scrollRef?.current) scrollRef.current.scrollTo({ top: 0, behavior: 'smooth' }); + } + if (!visible) return null; return (