Split out common logic into private method and add inline comment for future visitors

This commit is contained in:
Dean Herbert 2021-04-13 15:35:57 +09:00
parent d9e3276d0e
commit fbc6fb8fc5
1 changed files with 6 additions and 2 deletions

View File

@ -58,11 +58,13 @@ public PathControlPointPiece(Slider slider, PathControlPoint controlPoint)
{
this.slider = slider;
ControlPoint = controlPoint;
PointsInSegment = slider.Path.PointsInSegment(ControlPoint);
// we don't want to run the path type update on construction as it may inadvertently change the slider.
cachePoints(slider);
slider.Path.Version.BindValueChanged(_ =>
{
PointsInSegment = slider.Path.PointsInSegment(ControlPoint);
cachePoints(slider);
updatePathType();
});
@ -206,6 +208,8 @@ protected override void OnDrag(DragEvent e)
protected override void OnDragEnd(DragEndEvent e) => changeHandler?.EndChange();
private void cachePoints(Slider slider) => PointsInSegment = slider.Path.PointsInSegment(ControlPoint);
/// <summary>
/// Handles correction of invalid path types.
/// </summary>