@@ -145,7 +145,7 @@ type ViewportProps<ChartProps> = {
145145 // The "committed range", whose endpoints correspond to 0 and 1.
146146 readonly timeRange : StartEndRange ;
147147 // The preview selection, whose endpoints correspond to viewportLeft and viewportRight.
148- readonly previewSelection : PreviewSelection ;
148+ readonly previewSelection : PreviewSelection | null ;
149149 // The left margin. Margins are outside the viewport but inside containerWidth.
150150 readonly marginLeft : CssPixels ;
151151 // The right margin. Margins are outside the viewport but inside containerWidth.
@@ -214,7 +214,7 @@ class ChartViewportImpl<OwnProps> extends React.PureComponent<
214214> {
215215 zoomScrollId : number = 0 ;
216216 _pendingPreviewSelectionUpdates : Array <
217- ( horizontalViewport : HorizontalViewport ) => PreviewSelection
217+ ( horizontalViewport : HorizontalViewport ) => PreviewSelection | null
218218 > = [ ] ;
219219 _container : HTMLDivElement | null = null ;
220220 _takeContainerRef = ( container : HTMLDivElement ) => {
@@ -235,10 +235,10 @@ class ChartViewportImpl<OwnProps> extends React.PureComponent<
235235 }
236236
237237 getHorizontalViewport (
238- previewSelection : PreviewSelection ,
238+ previewSelection : PreviewSelection | null ,
239239 timeRange : StartEndRange
240240 ) {
241- if ( previewSelection . hasSelection ) {
241+ if ( previewSelection ) {
242242 const { selectionStart, selectionEnd } = previewSelection ;
243243 const timeRangeLength = timeRange . end - timeRange . start ;
244244 return {
@@ -433,7 +433,7 @@ class ChartViewportImpl<OwnProps> extends React.PureComponent<
433433 * processes all queued updates from a requestAnimationFrame callback.
434434 */
435435 _addBatchedPreviewSelectionUpdate (
436- callback : ( param : HorizontalViewport ) => PreviewSelection
436+ callback : ( param : HorizontalViewport ) => PreviewSelection | null
437437 ) {
438438 if ( this . _pendingPreviewSelectionUpdates . length === 0 ) {
439439 requestAnimationFrame ( ( ) => this . _flushPendingPreviewSelectionUpdates ( ) ) ;
@@ -532,14 +532,10 @@ class ChartViewportImpl<OwnProps> extends React.PureComponent<
532532 viewportProps : { timeRange } ,
533533 } = this . props ;
534534 if ( newViewportLeft === 0 && newViewportRight === 1 ) {
535- return {
536- hasSelection : false ,
537- isModifying : false ,
538- } ;
535+ return null ;
539536 }
540537 const timeRangeLength = timeRange . end - timeRange . start ;
541538 return {
542- hasSelection : true ,
543539 isModifying : false ,
544540 selectionStart : timeRange . start + timeRangeLength * newViewportLeft ,
545541 selectionEnd : timeRange . start + timeRangeLength * newViewportRight ,
@@ -722,10 +718,7 @@ class ChartViewportImpl<OwnProps> extends React.PureComponent<
722718 // Calculate left and right in terms of the unit interval of the profile range.
723719 const viewportLength = viewportRight - viewportLeft ;
724720 if ( viewportLength >= 1 ) {
725- return {
726- hasSelection : false ,
727- isModifying : false ,
728- } ;
721+ return null ;
729722 }
730723 const viewportPixelWidth = containerWidth - marginLeft - marginRight ;
731724 const unitOffsetX = offsetX * ( viewportLength / viewportPixelWidth ) ;
@@ -742,7 +735,6 @@ class ChartViewportImpl<OwnProps> extends React.PureComponent<
742735
743736 const timeRangeLength = timeRange . end - timeRange . start ;
744737 return {
745- hasSelection : true ,
746738 isModifying : false ,
747739 selectionStart : timeRange . start + timeRangeLength * newViewportLeft ,
748740 selectionEnd : timeRange . start + timeRangeLength * newViewportRight ,
0 commit comments