This repository was archived by the owner on Jun 24, 2025. It is now read-only.
File tree Expand file tree Collapse file tree 1 file changed +25
-4
lines changed Expand file tree Collapse file tree 1 file changed +25
-4
lines changed Original file line number Diff line number Diff line change @@ -378,16 +378,37 @@ export default class TabRowWidget extends BasicWidget {
378378 }
379379
380380 scrollTabContainer ( direction : number , behavior : ScrollBehavior = "smooth" ) {
381- const currentScrollLeft = this . $tabScrollingContainer [ 0 ] ?. scrollLeft ;
382- this . $tabScrollingContainer [ 0 ] . scrollTo ( {
383- left : currentScrollLeft + direction ,
381+ this . $tabScrollingContainer [ 0 ] . scrollBy ( {
382+ left : direction ,
384383 behavior
385384 } ) ;
386385 } ;
387386
388387 setupScrollEvents ( ) {
388+ let deltaX = 0 ;
389+ let isScrolling = false ;
390+ const stepScroll = ( ) => {
391+ if ( Math . abs ( deltaX ) > 5 ) {
392+ const step = Math . round ( deltaX * 0.2 ) ;
393+ deltaX -= step ;
394+ this . scrollTabContainer ( step , "instant" ) ;
395+ requestAnimationFrame ( stepScroll ) ;
396+ } else {
397+ this . scrollTabContainer ( deltaX , "instant" ) ;
398+ deltaX = 0 ;
399+ isScrolling = false ;
400+ }
401+ } ;
389402 this . $tabScrollingContainer [ 0 ] . addEventListener ( 'wheel' , ( event ) => {
390- this . scrollTabContainer ( event . deltaY * 1.5 ) ;
403+ if ( ! event . shiftKey || event . deltaX === 0 ) {
404+ event . preventDefault ( ) ;
405+ // Clamp deltaX between TAB_CONTAINER_MIN_WIDTH and TAB_CONTAINER_MIN_WIDTH * 3
406+ deltaX += Math . sign ( event . deltaY ) * Math . max ( Math . min ( Math . abs ( event . deltaY ) , TAB_CONTAINER_MIN_WIDTH * 3 ) , TAB_CONTAINER_MIN_WIDTH ) ;
407+ if ( ! isScrolling ) {
408+ isScrolling = true ;
409+ stepScroll ( ) ;
410+ }
411+ }
391412 } ) ;
392413
393414 this . $scrollButtonLeft [ 0 ] . addEventListener ( 'click' , ( ) => this . scrollTabContainer ( - 200 ) ) ;
You can’t perform that action at this time.
0 commit comments