11import React , { type FC , type PropsWithChildren , useCallback , useEffect , useRef , useState } from 'react' ;
22import classNames from 'classnames' ;
3+ import useMediaQuery from '@mui/material/useMediaQuery' ;
34import useElementSize from 'hooks/useElementSize' ;
5+ import { FINE_POINTER_MEDIA_QUERY } from 'utils/pointer' ;
46import layoutManager from '../../components/layoutManager' ;
57import dom from '../../utils/dom' ;
68import browser from '../../scripts/browser' ;
@@ -34,6 +36,7 @@ const Scroller: FC<PropsWithChildren<ScrollerProps>> = ({
3436 children
3537} ) => {
3638 const [ scrollRef , size ] = useElementSize ( ) ;
39+ const hasFinePointer = useMediaQuery ( FINE_POINTER_MEDIA_QUERY ) ;
3740
3841 const [ showControls , setShowControls ] = useState ( false ) ;
3942 const [ scrollState , setScrollState ] = useState ( {
@@ -158,7 +161,7 @@ const Scroller: FC<PropsWithChildren<ScrollerProps>> = ({
158161 return ;
159162 }
160163
161- const enableScrollButtons = layoutManager . desktop && ! browser . touch && isHorizontalEnabled && isScrollButtonsEnabled ;
164+ const enableScrollButtons = layoutManager . desktop && hasFinePointer && isHorizontalEnabled && isScrollButtonsEnabled ;
162165
163166 const options = {
164167 horizontal : isHorizontalEnabled ,
@@ -195,9 +198,10 @@ const Scroller: FC<PropsWithChildren<ScrollerProps>> = ({
195198 capture : false ,
196199 passive : true
197200 } ) ;
198- setShowControls ( true ) ;
199201 }
200202
203+ setShowControls ( enableScrollButtons ) ;
204+
201205 return ( ) => {
202206 if ( scrollerFactoryRef . current ) {
203207 scrollerFactoryRef . current . destroy ( ) ;
@@ -211,6 +215,7 @@ const Scroller: FC<PropsWithChildren<ScrollerProps>> = ({
211215 } ;
212216 } , [
213217 addScrollEventListener ,
218+ hasFinePointer ,
214219 initCenterFocus ,
215220 isAllowNativeSmoothScrollEnabled ,
216221 isCenterFocusEnabled ,
0 commit comments