@@ -53,7 +53,7 @@ import {
5353 UserTimingMarksView ,
5454} from './content-views' ;
5555import { COLORS } from './content-views/constants' ;
56- import { clampState } from './view-base/utils/scrollState' ;
56+ import { clampState , moveStateToRange } from './view-base/utils/scrollState' ;
5757import EventTooltip from './EventTooltip' ;
5858import { RegistryContext } from 'react-devtools-shared/src/devtools/ContextMenu/Contexts' ;
5959import ContextMenu from 'react-devtools-shared/src/devtools/ContextMenu/ContextMenu' ;
@@ -109,14 +109,24 @@ const zoomToBatch = (
109109 data : ReactProfilerData ,
110110 measure : ReactMeasure ,
111111 viewState : ViewState ,
112+ width : number ,
112113) => {
113114 const { batchUID} = measure ;
114- const [ startTime , stopTime ] = getBatchRange ( batchUID , data ) ;
115-
116- viewState . updateHorizontalScrollState ( {
117- offset : startTime ,
118- length : stopTime - startTime ,
115+ const [ rangeStart , rangeEnd ] = getBatchRange ( batchUID , data ) ;
116+
117+ // Convert from time range to ScrollState
118+ const scrollState = moveStateToRange ( {
119+ state : viewState . horizontalScrollState ,
120+ rangeStart,
121+ rangeEnd,
122+ contentLength : data . duration ,
123+
124+ minContentLength : data . duration * MIN_ZOOM_LEVEL ,
125+ maxContentLength : data . duration * MAX_ZOOM_LEVEL ,
126+ containerLength : width ,
119127 } ) ;
128+
129+ viewState . updateHorizontalScrollState ( scrollState ) ;
120130} ;
121131
122132type AutoSizedCanvasProps = { |
@@ -650,7 +660,7 @@ function AutoSizedCanvas({
650660 { measure !== null && (
651661 < ContextMenuItem
652662 onClick = { ( ) =>
653- zoomToBatch ( contextData . data , measure , viewState )
663+ zoomToBatch ( contextData . data , measure , viewState , width )
654664 }
655665 title = "Zoom to batch" >
656666 Zoom to batch
0 commit comments