private Size containerSize = new Size(0, 0);
private ScrollbarStyle scrollbarStyle => ViewStyle as ScrollbarStyle;
private bool mScrollEnabled = true;
+ private float previousPosition;
#endregion Fields
}
calculator.contentLength = contentLength > 0.0f ? contentLength : 0.0f;
+ previousPosition = calculator.currentPosition;
calculator.currentPosition = position;
thumbVisual.Size = calculator.CalculateThumbSize(ThumbThickness, trackVisual.Size);
return;
}
+ previousPosition = calculator.currentPosition;
calculator.currentPosition = position;
thumbVisual.Position = calculator.CalculateThumbScrollPosition(trackVisual.Size, thumbVisual.Position, TrackPadding);
}
}
+ /// <inheritdoc/>
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public override Position ScrollPosition
+ {
+ get
+ {
+ if (calculator == null)
+ {
+ return new Position(0.0f, 0.0f);
+ }
+
+ float length = Math.Min(Math.Max(calculator.currentPosition, 0.0f), calculator.contentLength - calculator.visibleLength);
+
+ if (calculator is HorizontalCalculator)
+ {
+ return new Position(length, 0.0f);
+ }
+ else
+ {
+ return new Position(0.0f, length);
+ }
+ }
+ }
+
+ /// <inheritdoc/>
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public override Position ScrollCurrentPosition
+ {
+ get
+ {
+ if (calculator == null)
+ {
+ return new Position(0.0f, 0.0f);
+ }
+
+ float length = Math.Min(Math.Max(calculator.currentPosition, 0.0f), calculator.contentLength - calculator.visibleLength);
+
+ if (thumbPositionAnimation != null)
+ {
+ float progress = thumbPositionAnimation.CurrentProgress;
+ float previousLength = Math.Min(Math.Max(previousPosition, 0.0f), calculator.contentLength - calculator.visibleLength);
+
+ length = ((1.0f - progress) * previousLength) + (progress * length);
+ }
+
+ if (calculator is HorizontalCalculator)
+ {
+ return new Position(length, 0.0f);
+ }
+ else
+ {
+ return new Position(0.0f, length);
+ }
+ }
+ }
+
#endregion Methods
[EditorBrowsable(EditorBrowsableState.Never)]
public abstract bool ScrollEnabled { get; set; }
+ /// <summary>
+ /// Scroll position given to ScrollTo or Update.
+ /// </summary>
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public abstract Position ScrollPosition { get; }
+
+ /// <summary>
+ /// Current scroll position in the middle of ScrollTo or Update animation.
+ /// </summary>
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public abstract Position ScrollCurrentPosition { get; }
+
#endregion Methods
}
}
private ArcVisual thumbVisual;
private float contentLength;
private float visibleLength;
+ private float previousPosition;
private float currentPosition;
private float directionAlpha;
private Size containerSize = new Size(0, 0);
[EditorBrowsable(EditorBrowsableState.Never)]
public override void Update(float contentLength, float position, uint durationMs = 0, AlphaFunction alphaFunction = null)
{
+ this.previousPosition = this.currentPosition;
this.currentPosition = position;
this.contentLength = contentLength > 0.0f ? contentLength : 0.0f;
[EditorBrowsable(EditorBrowsableState.Never)]
public override void ScrollTo(float position, uint durationMs = 0, AlphaFunction alphaFunction = null)
{
+ previousPosition = currentPosition;
currentPosition = position;
if (mScrollEnabled == false)
}
}
+ /// <inheritdoc/>
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public override Position ScrollPosition
+ {
+ get
+ {
+ bool isHorizontal = (directionAlpha == 270.0f) ? true : false;
+ float length = Math.Min(Math.Max(currentPosition, 0.0f), contentLength - visibleLength);
+
+ return (isHorizontal ? new Position(length, 0.0f) : new Position(0.0f, length));
+ }
+ }
+
+ /// <inheritdoc/>
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public override Position ScrollCurrentPosition
+ {
+ get
+ {
+ bool isHorizontal = (directionAlpha == 270.0f) ? true : false;
+ float length = Math.Min(Math.Max(currentPosition, 0.0f), contentLength - visibleLength);
+
+ if (thumbStartAngleAnimation != null)
+ {
+ float progress = thumbStartAngleAnimation.CurrentProgress;
+ float previousLength = Math.Min(Math.Max(previousPosition, 0.0f), contentLength - visibleLength);
+
+ length = ((1.0f - progress) * previousLength) + (progress * length);
+ }
+
+ return (isHorizontal ? new Position(length, 0.0f) : new Position(0.0f, length));
+ }
+ }
+
#endregion Methods
}
}