This commit is contained in:
NaBian committed 2020-09-26 17:38:26 +08:00
1 parent 4b44ec56b5
commit 5b2a521d6d
2 files changed
+7 -7

No files matched your search

@@ -76,7 +76,7 @@ namespace HandyControl.Controls
CurrentVerticalOffset = VerticalOffset; CurrentVerticalOffset = VerticalOffset;
} }
_totalVerticalOffset = Math.Min(Math.Max(0, _totalVerticalOffset - e.Delta), ScrollableHeight); _totalVerticalOffset = Math.Min(Math.Max(0, _totalVerticalOffset - e.Delta), ScrollableHeight);
ScrollToVerticalOffsetInternal(_totalVerticalOffset); ScrollToVerticalOffsetWithAnimation(_totalVerticalOffset);
} }
else else
{ {
@@ -86,7 +86,7 @@ namespace HandyControl.Controls
CurrentHorizontalOffset = HorizontalOffset; CurrentHorizontalOffset = HorizontalOffset;
} }
_totalHorizontalOffset = Math.Min(Math.Max(0, _totalHorizontalOffset - e.Delta), ScrollableWidth); _totalHorizontalOffset = Math.Min(Math.Max(0, _totalHorizontalOffset - e.Delta), ScrollableWidth);
ScrollToHorizontalOffsetInternal(_totalHorizontalOffset); ScrollToHorizontalOffsetWithAnimation(_totalHorizontalOffset);
} }
} }
@@ -97,10 +97,10 @@ namespace HandyControl.Controls
_totalVerticalOffset = VerticalOffset; _totalVerticalOffset = VerticalOffset;
CurrentVerticalOffset = VerticalOffset; CurrentVerticalOffset = VerticalOffset;
} }
ScrollToVerticalOffsetInternal(0, milliseconds); ScrollToVerticalOffsetWithAnimation(0, milliseconds);
} }
internal void ScrollToVerticalOffsetInternal(double offset, double milliseconds = 500) public void ScrollToVerticalOffsetWithAnimation(double offset, double milliseconds = 500)
{ {
var animation = AnimationHelper.CreateAnimation(offset, milliseconds); var animation = AnimationHelper.CreateAnimation(offset, milliseconds);
animation.EasingFunction = new CubicEase animation.EasingFunction = new CubicEase
@@ -118,7 +118,7 @@ namespace HandyControl.Controls
BeginAnimation(CurrentVerticalOffsetProperty, animation, HandoffBehavior.Compose); BeginAnimation(CurrentVerticalOffsetProperty, animation, HandoffBehavior.Compose);
} }
internal void ScrollToHorizontalOffsetInternal(double offset, double milliseconds = 500) public void ScrollToHorizontalOffsetWithAnimation(double offset, double milliseconds = 500)
{ {
var animation = AnimationHelper.CreateAnimation(offset, milliseconds); var animation = AnimationHelper.CreateAnimation(offset, milliseconds);
animation.EasingFunction = new CubicEase animation.EasingFunction = new CubicEase
@@ -307,11 +307,11 @@ namespace HandyControl.Controls
private void Menu_Closed(object sender, RoutedEventArgs e) => _buttonOverflow.IsChecked = false; private void Menu_Closed(object sender, RoutedEventArgs e) => _buttonOverflow.IsChecked = false;
private void ButtonScrollRight_Click(object sender, RoutedEventArgs e) => private void ButtonScrollRight_Click(object sender, RoutedEventArgs e) =>
_scrollViewerOverflow.ScrollToHorizontalOffsetInternal(Math.Min( _scrollViewerOverflow.ScrollToHorizontalOffsetWithAnimation(Math.Min(
_scrollViewerOverflow.CurrentHorizontalOffset + TabItemWidth, _scrollViewerOverflow.ScrollableWidth)); _scrollViewerOverflow.CurrentHorizontalOffset + TabItemWidth, _scrollViewerOverflow.ScrollableWidth));
private void ButtonScrollLeft_Click(object sender, RoutedEventArgs e) => private void ButtonScrollLeft_Click(object sender, RoutedEventArgs e) =>
_scrollViewerOverflow.ScrollToHorizontalOffsetInternal(Math.Max( _scrollViewerOverflow.ScrollToHorizontalOffsetWithAnimation(Math.Max(
_scrollViewerOverflow.CurrentHorizontalOffset - TabItemWidth, 0)); _scrollViewerOverflow.CurrentHorizontalOffset - TabItemWidth, 0));
private void ButtonOverflow_Click(object sender, RoutedEventArgs e) private void ButtonOverflow_Click(object sender, RoutedEventArgs e)