@@ -50,6 +50,17 @@ const MermaidInner: React.FC<MermaidProps> = ({ chart }) => {
5050 const MAX_ZOOM = 2 ;
5151 const MIN_ZOOM = 0.5 ;
5252 const MAX_PAN = 300 ;
53+ const MOBILE_BREAKPOINT = 672 ;
54+
55+ const [ isMobile , setIsMobile ] = useState ( false ) ;
56+
57+ useEffect ( ( ) => {
58+ const mq = window . matchMedia ( `(max-width: ${ MOBILE_BREAKPOINT } px)` ) ;
59+ setIsMobile ( mq . matches ) ;
60+ const handler = ( e : MediaQueryListEvent ) => setIsMobile ( e . matches ) ;
61+ mq . addEventListener ( 'change' , handler ) ;
62+ return ( ) => mq . removeEventListener ( 'change' , handler ) ;
63+ } , [ ] ) ;
5364
5465 const getCurrentTheme = useCallback ( ( ) : 'neutral' | 'dark' => {
5566 const carbonTheme = document . documentElement . getAttribute ( 'data-carbon-theme' ) ;
@@ -495,11 +506,13 @@ const MermaidInner: React.FC<MermaidProps> = ({ chart }) => {
495506 onMouseMove = { handleMouseMove }
496507 onMouseUp = { handleMouseUp }
497508 onMouseLeave = { handleMouseLeave }
498- onTouchStart = { handleTouchStart }
499- onTouchMove = { handleTouchMove }
500- onTouchEnd = { handleTouchEnd }
509+ { ...( ! isMobile && {
510+ onTouchStart : handleTouchStart ,
511+ onTouchMove : handleTouchMove ,
512+ onTouchEnd : handleTouchEnd ,
513+ } ) }
501514 style = { {
502- cursor : loadingState === 'success' ? ( isDragging ? 'grabbing' : 'grab' ) : 'default' ,
515+ cursor : loadingState === 'success' && ! isMobile ? ( isDragging ? 'grabbing' : 'grab' ) : 'default' ,
503516 display : loadingState === 'success' ? 'flex' : 'none' ,
504517 ...( containerHeight && {
505518 height : `${ containerHeight } px` ,
0 commit comments