1010import type { Snapshot , ReactProfilerData } from '../types' ;
1111import type {
1212 Interaction ,
13- MouseMoveInteraction ,
13+ Point ,
1414 Rect ,
1515 Size ,
1616 Surface ,
@@ -67,6 +67,10 @@ export class SnapshotsView extends View {
6767 // draw them at fixed intervals and just show the nearest one.
6868 while ( x < visibleArea . origin . x + visibleArea . size . width ) {
6969 const snapshot = this . _findClosestSnapshot ( x ) ;
70+ if ( snapshot === null ) {
71+ // This shold never happen.
72+ break ;
73+ }
7074
7175 const scaledHeight = SNAPSHOT_HEIGHT ;
7276 const scaledWidth = ( snapshot . width * SNAPSHOT_HEIGHT ) / snapshot . height ;
@@ -97,7 +101,11 @@ export class SnapshotsView extends View {
97101 handleInteraction ( interaction : Interaction , viewRefs : ViewRefs ) {
98102 switch ( interaction . type ) {
99103 case 'mousemove' :
100- this . _handleMouseMove ( interaction , viewRefs ) ;
104+ case 'wheel-control' :
105+ case 'wheel-meta' :
106+ case 'wheel-plain' :
107+ case 'wheel-shift' :
108+ this . _updateHover ( interaction . payload . location , viewRefs ) ;
101109 break ;
102110 }
103111 }
@@ -125,6 +133,14 @@ export class SnapshotsView extends View {
125133 context . clip ( ) ;
126134 }
127135
136+ context . fillStyle = COLORS . REACT_RESIZE_BAR_BORDER ;
137+ context . fillRect (
138+ imageRect . origin . x ,
139+ imageRect . origin . y ,
140+ imageRect . size . width ,
141+ imageRect . size . height ,
142+ ) ;
143+
128144 // $FlowFixMe Flow doesn't know about the 9 argument variant of drawImage()
129145 context . drawImage (
130146 snapshot . image ,
@@ -138,20 +154,20 @@ export class SnapshotsView extends View {
138154 snapshot . height ,
139155
140156 // Canvas coordinates
141- imageRect . origin . x ,
142- imageRect . origin . y ,
157+ imageRect . origin . x + BORDER_SIZE ,
158+ imageRect . origin . y + BORDER_SIZE ,
143159
144160 // Scaled image size
145- imageRect . size . width ,
146- imageRect . size . height ,
161+ imageRect . size . width - BORDER_SIZE * 2 ,
162+ imageRect . size . height - BORDER_SIZE * 2 ,
147163 ) ;
148164
149165 if ( shouldClip ) {
150166 context . restore ( ) ;
151167 }
152168 }
153169
154- _findClosestSnapshot ( x : number ) : Snapshot {
170+ _findClosestSnapshot ( x : number ) : Snapshot | null {
155171 const frame = this . frame ;
156172 const scaleFactor = positioningScaleFactor (
157173 this . _intrinsicSize . width ,
@@ -178,28 +194,25 @@ export class SnapshotsView extends View {
178194 }
179195 }
180196
181- return snapshots [ stopIndex ] ;
197+ return snapshots [ stopIndex ] || null ;
182198 }
183199
184200 /**
185201 * @private
186202 */
187- _handleMouseMove ( interaction : MouseMoveInteraction , viewRefs : ViewRefs ) {
203+ _updateHover ( location : Point , viewRefs : ViewRefs ) {
188204 const { onHover, visibleArea} = this ;
189205 if ( ! onHover ) {
190206 return ;
191207 }
192208
193- const { location} = interaction . payload ;
194209 if ( ! rectContainsPoint ( location , visibleArea ) ) {
195210 onHover ( null ) ;
196211 return ;
197212 }
198213
199214 const snapshot = this . _findClosestSnapshot ( location . x ) ;
200- if ( snapshot ) {
201- this . currentCursor = 'context-menu' ;
202- viewRefs . hoveredView = this ;
215+ if ( snapshot !== null ) {
203216 onHover ( snapshot ) ;
204217 } else {
205218 onHover ( null ) ;
0 commit comments