@@ -527,6 +527,34 @@ define(function (require, exports, module) {
527527 ) ;
528528 }
529529
530+ /**
531+ * this function sets up mouse wheel scrolling functionality for the tab bars
532+ * when the mouse wheel is scrolled up, the tab bar will scroll to the left
533+ * when its scrolled down, the tab bar will scroll to the right
534+ */
535+ function setupTabBarScrolling ( ) {
536+
537+ // common handler for both the tab bars
538+ function handleMouseWheel ( e ) {
539+ // get the tab bar element that is being scrolled
540+ const $scrolledTabBar = $ ( this ) ;
541+
542+ // A negative deltaY means scrolling up so we need to scroll to the left,
543+ // positive means scrolling down so we need to scroll to the right
544+ // here we calculate the scroll amount (pixels)
545+ // and multiply by 2.5 for increasing the scroll amount
546+ const scrollAmount = e . originalEvent . deltaY * 2.5 ;
547+
548+ // calculate the new scroll position
549+ const newScrollLeft = $scrolledTabBar . scrollLeft ( ) + scrollAmount ;
550+
551+ // apply the new scroll position
552+ $scrolledTabBar . scrollLeft ( newScrollLeft ) ;
553+ }
554+
555+ // attach the wheel event handler to both tab bars
556+ $ ( document ) . on ( 'wheel' , '#phoenix-tab-bar, #phoenix-tab-bar-2' , handleMouseWheel ) ;
557+ }
530558
531559 AppInit . appReady ( function ( ) {
532560 _registerCommands ( ) ;
@@ -548,5 +576,8 @@ define(function (require, exports, module) {
548576
549577 Overflow . init ( ) ;
550578 DragDrop . init ( $ ( '#phoenix-tab-bar' ) , $ ( '#phoenix-tab-bar-2' ) ) ;
579+
580+ // setup the mouse wheel scrolling
581+ setupTabBarScrolling ( ) ;
551582 } ) ;
552583} ) ;
0 commit comments