@@ -337,6 +337,7 @@ protected virtual void ScrollSetup() {
337337 var areaHeight = this . ChildPaddedArea . Height ;
338338 // the max value of the scroll bar is the amount of non-scaled pixels taken up by overflowing components
339339 var scrollBarMax = Math . Max ( 0 , ( childrenHeight - areaHeight ) / this . Scale ) ;
340+
340341 // avoid an infinite show/hide oscillation that occurs while updating our area by simply using the maximum recent height in that case
341342 var hiddenChange = this . ScrollBar . AutoHideWhenEmpty && this . ScrollBar . MaxValue > Element . Epsilon != scrollBarMax > Element . Epsilon ;
342343 if ( hiddenChange ) {
@@ -348,29 +349,30 @@ protected virtual void ScrollSetup() {
348349 if ( this . scrollBarMaxHistory [ 0 ] . Equals ( this . scrollBarMaxHistory [ 2 ] , Element . Epsilon ) && this . scrollBarMaxHistory [ 1 ] . Equals ( scrollBarMax , Element . Epsilon ) )
349350 scrollBarMax = Math . Max ( scrollBarMax , this . scrollBarMaxHistory . Max ( ) ) ;
350351 }
352+ if ( hiddenChange && ! scrollBarMax . Equals ( this . scrollBarMaxHistory [ 2 ] , Element . Epsilon ) ) {
353+ this . scrollBarMaxHistory [ 0 ] = this . scrollBarMaxHistory [ 1 ] ;
354+ this . scrollBarMaxHistory [ 1 ] = this . scrollBarMaxHistory [ 2 ] ;
355+ this . scrollBarMaxHistory [ 2 ] = scrollBarMax ;
356+ this . scrollBarMaxHistoryDirty = true ;
357+ }
358+
351359 if ( ! this . ScrollBar . MaxValue . Equals ( scrollBarMax , Element . Epsilon ) ) {
352- if ( hiddenChange && ! scrollBarMax . Equals ( this . scrollBarMaxHistory [ 2 ] , Element . Epsilon ) ) {
353- this . scrollBarMaxHistory [ 0 ] = this . scrollBarMaxHistory [ 1 ] ;
354- this . scrollBarMaxHistory [ 1 ] = this . scrollBarMaxHistory [ 2 ] ;
355- this . scrollBarMaxHistory [ 2 ] = scrollBarMax ;
356- this . scrollBarMaxHistoryDirty = true ;
357- }
358360 this . ScrollBar . MaxValue = scrollBarMax ;
359361 this . relevantChildrenDirty = true ;
362+ }
360363
361- // update child padding based on whether the scroll bar is visible
362- var childOffset = this . ScrollBar . IsHidden ? 0 : this . ScrollerSize . Value . X + this . ScrollBarOffset ;
363- var childOffsetDelta = childOffset - this . scrollBarChildOffset ;
364- if ( ! childOffsetDelta . Equals ( 0 , Element . Epsilon ) ) {
365- this . scrollBarChildOffset = childOffset ;
366- this . ChildPadding += new Padding ( 0 , childOffsetDelta , 0 , 0 ) ;
367- }
368-
369- // the scroller height has the same relation to the scroll bar height as the visible area has to the total height of the panel's content
370- var scrollerHeight = Math . Min ( areaHeight / ( scrollBarMax * this . Scale + areaHeight ) / this . Scale , 1 ) * this . ScrollBar . Area . Height ;
371- this . ScrollBar . ScrollerSize = new Vector2 ( this . ScrollerSize . Value . X , Math . Max ( this . ScrollerSize . Value . Y , scrollerHeight ) ) ;
364+ // update child padding based on whether the scroll bar is visible
365+ var childOffset = this . ScrollBar . IsHidden ? 0 : this . ScrollerSize . Value . X + this . ScrollBarOffset ;
366+ var childOffsetDelta = childOffset - this . scrollBarChildOffset ;
367+ if ( ! childOffsetDelta . Equals ( 0 , Element . Epsilon ) ) {
368+ this . scrollBarChildOffset = childOffset ;
369+ this . ChildPadding += new Padding ( 0 , childOffsetDelta , 0 , 0 ) ;
372370 }
373371
372+ // the scroller height has the same relation to the scroll bar height as the visible area has to the total height of the panel's content
373+ var scrollerHeight = Math . Min ( areaHeight / ( scrollBarMax * this . Scale + areaHeight ) / this . Scale , 1 ) * this . ScrollBar . Area . Height ;
374+ this . ScrollBar . ScrollerSize = new Vector2 ( this . ScrollerSize . Value . X , Math . Max ( this . ScrollerSize . Value . Y , scrollerHeight ) ) ;
375+
374376 // update the render target
375377 var area = ( Rectangle ) this . GetRenderTargetArea ( ) ;
376378 if ( area . Width <= 0 || area . Height <= 0 ) {
0 commit comments