File tree Expand file tree Collapse file tree 1 file changed +14
-1
lines changed
Expand file tree Collapse file tree 1 file changed +14
-1
lines changed Original file line number Diff line number Diff line change @@ -1097,13 +1097,26 @@ if __name__ == "__main__":
10971097 const lineOffsetTop = lineEl . offsetTop ;
10981098 const containerHeight = container . clientHeight ;
10991099 const lineHeight = lineEl . clientHeight ;
1100+ const currentScroll = container . scrollTop ;
11001101
11011102 // Center the line in the container
11021103 const scrollTarget = lineOffsetTop - ( containerHeight / 2 ) + ( lineHeight / 2 ) ;
11031104
1105+ // Determine scroll direction and add/subtract offset accordingly
1106+ const extraOffset = 30 ; // Extra pixels to ensure visibility
1107+ let finalTarget ;
1108+
1109+ if ( scrollTarget > currentScroll ) {
1110+ // Scrolling down - add extra offset
1111+ finalTarget = scrollTarget + extraOffset ;
1112+ } else {
1113+ // Scrolling up - subtract extra offset
1114+ finalTarget = scrollTarget - extraOffset ;
1115+ }
1116+
11041117 // Smoothly scroll to the target position
11051118 container . scrollTo ( {
1106- top : Math . max ( 0 , scrollTarget ) ,
1119+ top : Math . max ( 0 , finalTarget ) ,
11071120 behavior : 'smooth'
11081121 } ) ;
11091122 }
You can’t perform that action at this time.
0 commit comments