@@ -2135,8 +2135,6 @@ void SetupAxis(ImAxis idx, const char* label, ImPlotAxisFlags flags) {
21352135 if (plot.JustCreated || flags != axis.PreviousFlags )
21362136 axis.Flags = flags;
21372137 axis.PreviousFlags = flags;
2138- // cache previous range
2139- axis.PreviousRange = ImPlotRange (axis.Range .Min , axis.Range .Max );
21402138 // enable axis
21412139 axis.Enabled = true ;
21422140 // set label
@@ -2632,6 +2630,11 @@ void SetupFinish() {
26322630 }
26332631 }
26342632
2633+ // cache previous ranges
2634+ for (int i = 0 ; i < ImAxis_COUNT; i++) {
2635+ plot.Axes [i].PreviousRange = ImPlotRange (plot.Axes [i].Range .Min , plot.Axes [i].Range .Max );
2636+ }
2637+
26352638 // INPUT ------------------------------------------------------------------
26362639 if (!ImHasFlag (plot.Flags , ImPlotFlags_NoInputs))
26372640 UpdateInput (plot);
@@ -3741,14 +3744,14 @@ bool IsPlotHovered() {
37413744 return gp.CurrentPlot ->Hovered ;
37423745}
37433746
3744- bool IsPlotChanging ( ) {
3747+ bool IsAxisRangeChanging (ImAxis axis ) {
37453748 ImPlotContext& gp = *GImPlot;
3746- IM_ASSERT_USER_ERROR (gp.CurrentPlot != nullptr , " IsPlotChanging () needs to be called between BeginPlot() and EndPlot()!" );
3749+ IM_ASSERT_USER_ERROR (gp.CurrentPlot != nullptr , " IsAxisRangeChanging () needs to be called between BeginPlot() and EndPlot()!" );
37473750 SetupLock ();
37483751 ImPlotPlot& plot = *gp.CurrentPlot ;
3749- bool differentX = plot.Axes [plot. CurrentX ].Range .Min != plot.Axes [plot. CurrentX ].PreviousRange .Min || plot. Axes [plot. CurrentX ]. Range . Max != plot. Axes [plot. CurrentX ]. PreviousRange . Max ;
3750- bool differentY = plot.Axes [plot. CurrentY ].Range .Min != plot. Axes [plot. CurrentY ]. PreviousRange . Min || plot. Axes [plot. CurrentY ]. Range . Max != plot.Axes [plot. CurrentY ].PreviousRange .Max ;
3751- return differentX || differentY ;
3752+ bool isMinDifferent = plot.Axes [axis ].Range .Min != plot.Axes [axis ].PreviousRange .Min ;
3753+ bool isMaxDifferent = plot.Axes [axis ].Range .Max != plot.Axes [axis ].PreviousRange .Max ;
3754+ return isMinDifferent || isMaxDifferent ;
37523755}
37533756
37543757bool IsAxisHovered (ImAxis axis) {
0 commit comments