HandyControl icon indicating copy to clipboard operation
HandyControl copied to clipboard

ScrollToVerticalOffsetWithAnimation doesn't work properly.

Open Ustronger opened this issue 2 years ago • 2 comments

Describe the bug

This function always plays the animation from where the last animation ended rather than the actual starting point.

Suppose the last animation ended at HorizontalOffset 100. If I drag the ScrollBar to change the HorizontalOffset to 200, when I invoke the function again the animation will begin from 100 rather then from 200.

I went through the source code for ScrollViewer and found that this function plays animates by controlling CurrentHorizontalOffset. But this is an internal value and is set only when the function has been invoked. If the HorizontalOffset is changed in some other way, this value will not be changed.

As a result, the animation that this function plays always starts at the end of the last animation rather than the actual starting point.

Steps to reproduce the bug

  1. Create a new ScrollViewer and name it myscrollviewer.
  2. Create a new button and create the following handler. private void button_Click(object sender, RoutedEventArgs e) { myscrollviewer.ScrollToHorizontalOffsetWithAnimation(200, 1000); }
  3. Launch the window and drag the HorizontalScrollBar some distance to the right.
  4. Click the button and you will find that the starting point of the animation is incorrect.

Expected behavior

The animation should begin from the actual position of the ScrollBar to the end position. It may be useful to add an argument to the function to sets the starting point of the animation.

Screenshots

bandicam 2022-05-25 02-59-44-922

NuGet package version

HandyControl 3.3.0

IDE

Visual Studio 2022

Framework type

.Net Framework 4.8

Windows version

May 2021 Update (19043)

Additional context

No response

Ustronger avatar May 24 '22 19:05 Ustronger

I read the source code.,Delay effect only supports mouse wheel(vertical direction)。 You may need to rewrite the scrollbar component。

melinyi avatar Jun 01 '22 15:06 melinyi

I read the source code.,Delay effect only supports mouse wheel(vertical direction)。 You may need to rewrite the scrollbar component。

This function is a public method, though the default effect also invokes it. It may be more perfect if the function could call HorizontalOffset to get the current offset of the scrollbar and set it as the animation's start point.

Ustronger avatar Jun 05 '22 05:06 Ustronger