@@ -89,6 +89,7 @@ export type UpdateZoomSourcing = {
8989} ;
9090export type UpdateZoomChanges = Record < AxisID , ZoomState | undefined > ;
9191export type UpdateZoomParams = UpdateZoomSourcing & {
92+ isReset : boolean ;
9293 changes : UpdateZoomChanges ;
9394} ;
9495
@@ -294,7 +295,12 @@ export class ZoomManager extends BaseManager {
294295
295296 const changes = this . toCoreZoomState ( zoom ) ;
296297 this . lastRestoredState = deepFreeze ( deepClone ( changes ) ) ;
297- this . updateChanges ( { source : 'user-interaction' , sourceDetail : 'internal-restoreMemento' , changes } ) ;
298+ this . updateChanges ( {
299+ source : 'user-interaction' ,
300+ sourceDetail : 'internal-restoreMemento' ,
301+ changes,
302+ isReset : false ,
303+ } ) ;
298304 }
299305
300306 private findAxis ( axisId : AxisID ) : CartesianAxisLike | undefined {
@@ -321,7 +327,7 @@ export class ZoomManager extends BaseManager {
321327 this . state = changes ;
322328 this . lastRestoredState = refreshCoreState ( nextAxes , this . lastRestoredState ) ;
323329
324- this . updateChanges ( { source : 'chart-update' , sourceDetail : 'internal-setAxes' , changes } ) ;
330+ this . updateChanges ( { source : 'chart-update' , sourceDetail : 'internal-setAxes' , changes, isReset : false } ) ;
325331 }
326332
327333 public setIndependentAxes ( independent = true ) {
@@ -346,7 +352,7 @@ export class ZoomManager extends BaseManager {
346352
347353 public updateZoom ( { source, sourceDetail } : UpdateZoomSourcing , newZoom ?: AxisZoomState ) : boolean {
348354 const changes = this . toCoreZoomState ( newZoom ?? { } ) ;
349- return this . updateChanges ( { source, sourceDetail, changes } ) ;
355+ return this . updateChanges ( { source, sourceDetail, changes, isReset : false } ) ;
350356 }
351357
352358 private computeChangedAxesIds ( newState : UpdateZoomChanges ) : readonly AxisID [ ] {
@@ -367,7 +373,7 @@ export class ZoomManager extends BaseManager {
367373 }
368374
369375 public updateChanges ( params : UpdateZoomParams ) : boolean {
370- const { source, sourceDetail, changes } = params ;
376+ const { source, sourceDetail, isReset , changes } = params ;
371377 validateChanges ( changes ) ;
372378
373379 const changedAxes = this . computeChangedAxesIds ( changes ) ;
@@ -381,15 +387,20 @@ export class ZoomManager extends BaseManager {
381387 }
382388 this . state = newState ;
383389
384- return this . dispatch ( source , sourceDetail , changedAxes ) ;
390+ return this . dispatch ( source , sourceDetail , changedAxes , isReset ) ;
385391 }
386392
387- public resetZoom ( sourceDetail : ZoomEventSourceDetail ) {
388- this . updateChanges ( { source : 'reset' , sourceDetail, changes : this . getRestoredZoom ( ) } ) ;
393+ public resetZoom ( { source , sourceDetail } : UpdateZoomSourcing ) {
394+ this . updateChanges ( { source, sourceDetail, changes : this . getRestoredZoom ( ) , isReset : true } ) ;
389395 }
390396
391- public resetAxisZoom ( sourceDetail : ZoomEventSourceDetail , axisId : AxisID ) {
392- this . updateChanges ( { source : 'reset' , sourceDetail, changes : { [ axisId ] : this . getRestoredZoom ( ) [ axisId ] } } ) ;
397+ public resetAxisZoom ( { source, sourceDetail } : UpdateZoomSourcing , axisId : AxisID ) {
398+ this . updateChanges ( {
399+ source,
400+ sourceDetail,
401+ changes : { [ axisId ] : this . getRestoredZoom ( ) [ axisId ] } ,
402+ isReset : true ,
403+ } ) ;
393404 }
394405
395406 public panToBBox ( seriesRect : BBox , target : BoxBounds ) : boolean {
@@ -410,7 +421,12 @@ export class ZoomManager extends BaseManager {
410421
411422 const newZoom : AxisZoomState = calcPanToBBoxRatios ( seriesRect , zoom , target ) ;
412423 const changes = this . toCoreZoomState ( newZoom ) ;
413- return this . updateChanges ( { source : 'user-interaction' , sourceDetail : 'internal-panToBBox' , changes } ) ;
424+ return this . updateChanges ( {
425+ source : 'user-interaction' ,
426+ sourceDetail : 'internal-panToBBox' ,
427+ changes,
428+ isReset : false ,
429+ } ) ;
414430 }
415431
416432 // Fire this event to signal to listeners that the view is changing through a zoom and/or pan change.
@@ -439,7 +455,7 @@ export class ZoomManager extends BaseManager {
439455 const ratio = this . rangeToRatioAxis ( axis , { start } ) ;
440456 if ( ! ratio ) return ;
441457
442- this . updateChanges ( { source, sourceDetail, changes : { [ direction ] : ratio } } ) ;
458+ this . updateChanges ( { source, sourceDetail, changes : { [ direction ] : ratio } , isReset : false } ) ;
443459 }
444460
445461 public updateWith (
@@ -459,7 +475,7 @@ export class ZoomManager extends BaseManager {
459475 const ratio = this . rangeToRatioAxis ( axis , { start, end } ) ;
460476 if ( ! ratio ) return ;
461477
462- this . updateChanges ( { source, sourceDetail, changes : { [ direction ] : ratio } } ) ;
478+ this . updateChanges ( { source, sourceDetail, changes : { [ direction ] : ratio } , isReset : false } ) ;
463479 }
464480
465481 public getZoom ( ) : AxisZoomState | undefined {
@@ -574,7 +590,8 @@ export class ZoomManager extends BaseManager {
574590 private dispatch (
575591 source : AgZoomEventSource ,
576592 sourceDetail : ZoomEventSourceDetail ,
577- changedAxes : readonly AxisID [ ]
593+ changedAxes : readonly AxisID [ ] ,
594+ isReset : boolean
578595 ) : boolean {
579596 const { x, y } = this . getZoom ( ) ?? { } ;
580597 const state = this . state ;
@@ -583,6 +600,7 @@ export class ZoomManager extends BaseManager {
583600 const event = {
584601 source,
585602 sourceDetail,
603+ isReset,
586604 changedAxes,
587605 state,
588606 x,
0 commit comments