@@ -129,6 +129,8 @@ export default function PostContent({ data, space, loadSuggestions }) {
129129}
130130
131131const TitleContent = ( { title } ) => {
132+ const titleRef = useRef ( ) ;
133+ const [ offsetTop , setOffsetTop ] = useState ( 152 ) ;
132134 const [ scrollY , setScrollY ] = useState ( 0 ) ;
133135 const debouncedScrollHandler = useRef ( null ) ;
134136 const handleScroll = useCallback ( ( ) => {
@@ -138,8 +140,14 @@ const TitleContent = ({ title }) => {
138140 useEffect ( ( ) => { } , [ handleScroll ] ) ;
139141
140142 useEffect ( ( ) => {
143+ if ( ! titleRef . current ) {
144+ return ;
145+ }
146+ const { top, height } = titleRef . current . getBoundingClientRect ( ) ;
147+ setOffsetTop ( top + height - 66 ) ;
141148 debouncedScrollHandler . current = debounce ( handleScroll , 10 ) ;
142149 window . addEventListener ( "scroll" , debouncedScrollHandler . current ) ;
150+
143151 return ( ) => {
144152 if ( debouncedScrollHandler . current ) {
145153 debouncedScrollHandler . current . cancel ( ) ;
@@ -150,17 +158,19 @@ const TitleContent = ({ title }) => {
150158
151159 return (
152160 < >
153- < Title > { title } </ Title >
161+ < Title ref = { titleRef } > { title } </ Title >
154162 < div
155163 className = { cn (
156164 "fixed py-5 z-10 top-0 transform -translate-y-full left-0 w-full bg-fillBgPrimary border border-strokeBorderDefault shadow-shadowCardDefault" ,
157- scrollY > 180 && "translate-y-0" ,
165+ scrollY > offsetTop && "translate-y-0" ,
158166 ) }
159167 >
160- < div className = "max-w-[1144px] mx-auto md:px-8 px-5 flex relative" >
161- < ArrowCaretLeft className = "w-8 h-8 p-1 md:ml-8 ml-5 rounded-full border shadow absolute left-0 -translate-x-1/2 " />
162- < div className = "px-8 font-[700] text-base md:font-[600] md:text-[20px]" >
163- { title }
168+ < div className = "md:max-w-[1144px] mx-auto md:px-8 px-5 flex relative" >
169+ < div className = "w-full md:!w-[calc(100%-320px)] flex items-center" >
170+ < ArrowCaretLeft className = "w-8 h-8 p-1 md:ml-8 ml-5 rounded-full border shadow absolute left-0 -translate-x-1/2 " />
171+ < div className = "pl-8 md:px-8 font-[700] text-base md:font-[600] md:text-[20px] whitespace-nowrap overflow-hidden text-ellipsis" >
172+ { title }
173+ </ div >
164174 </ div >
165175 </ div >
166176 </ div >
0 commit comments