@@ -18,7 +18,7 @@ import { currentUserRole } from "../../atoms/currentUser";
1818import { useAtom } from "jotai" ;
1919
2020const ClaimView = ( { personality, claim, href, hideDescriptions } ) => {
21- const [ isAffixed , setIsAffixed ] = useState ( true ) ;
21+ const [ isAffixed , setIsAffixed ] = useState ( false ) ;
2222 const ref = useRef < HTMLDivElement | null > ( null ) ;
2323 const dispatch = useDispatch ( ) ;
2424 const { t } = useTranslation ( ) ;
@@ -44,19 +44,24 @@ const ClaimView = ({ personality, claim, href, hideDescriptions }) => {
4444 } , [ claim , claimContent , dispatch , isImage , personality , t ] ) ;
4545
4646 useEffect ( ( ) => {
47- const handleScroll = ( ) => {
4847 if ( ! ref . current ) return ;
49-
50- const { bottom } = ref . current . getBoundingClientRect ( ) ;
51- const windowHeight = window . innerHeight ;
52-
53- if ( bottom > windowHeight ) {
54- setIsAffixed ( true ) ;
55- } else {
56- setIsAffixed ( false ) ;
48+
49+ const scrollableSpeech = ref . current . scrollHeight > window . innerHeight ;
50+ if ( scrollableSpeech ) {
51+ setIsAffixed ( true ) ;
5752 }
58- } ;
59- window . addEventListener ( "scroll" , handleScroll ) ;
53+
54+ const handleScroll = ( ) => {
55+ const { bottom } = ref . current . getBoundingClientRect ( ) ;
56+ const isFixed = bottom > window . innerHeight ;
57+
58+ if ( isFixed ) {
59+ setIsAffixed ( true ) ;
60+ } else {
61+ setIsAffixed ( false ) ;
62+ }
63+ } ;
64+ window . addEventListener ( "scroll" , handleScroll ) ;
6065 } , [ ] ) ;
6166
6267 return (
0 commit comments