File tree Expand file tree Collapse file tree 1 file changed +1
-33
lines changed
Expand file tree Collapse file tree 1 file changed +1
-33
lines changed Original file line number Diff line number Diff line change @@ -365,39 +365,7 @@ const Table = <RecordType extends DefaultRecordType>(
365365 targetElement . scrollIntoView ( { block : align } ) ;
366366 if ( offset ) {
367367 const container = scrollBodyRef . current ;
368- const elementTop = ( targetElement as HTMLElement ) . offsetTop ;
369- const elementHeight = ( targetElement as HTMLElement ) . offsetHeight ;
370- const containerHeight = container . clientHeight ;
371- const elementBottom = elementTop + elementHeight ;
372- let targetTop : number ;
373- switch ( align ) {
374- case 'nearest' : {
375- const currentTop = container . scrollTop ;
376- const viewportBottom = currentTop + containerHeight ;
377- const targetWithOffset = elementTop + offset ;
378- const targetBottomWithOffset = elementBottom + offset ;
379-
380- if ( targetWithOffset < currentTop ) {
381- targetTop = targetWithOffset ;
382- } else if ( targetBottomWithOffset > viewportBottom ) {
383- targetTop = targetBottomWithOffset - containerHeight ;
384- } else {
385- targetTop = currentTop ;
386- }
387- break ;
388- }
389- case 'end' :
390- targetTop = elementBottom - containerHeight + offset ;
391- break ;
392- case 'center' :
393- targetTop = elementTop - ( containerHeight - elementHeight ) / 2 + offset ;
394- break ;
395- case 'start' :
396- default :
397- targetTop = elementTop + offset ;
398- }
399-
400- container . scrollTo ( { top : targetTop } ) ;
368+ container . scrollTo ( { top : container . scrollTop + offset } ) ;
401369 }
402370 }
403371 }
You can’t perform that action at this time.
0 commit comments