Skip to content

ScrollViewer expression animations extensions #3220

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Conversation

Sergio0694
Copy link
Member

@Sergio0694 Sergio0694 commented Apr 3, 2020

This PR is part of the group being tracked in #3108.

PR Type

What kind of change does this PR introduce?

  • Feature

What is the new behavior?

Two extension methods for the ScrollViewer class that can be used to easily create and start expression animations that bind the scrolling translation on a specified axis of the source scroller, to the offset on a given axis of a target control. This can be used to keep "in sync" the contents of a ScrollViewer with some overlays rendered on another surface that is not part of the ScrollViewer, as the expression animation will adjust the offset of the external surface to perfectly follow its content.

Here it is in action, you can see that there is some text inside a RichEditBox, and these new extensions are used to keep the text in sync with the text overlays (the dashed column guides and the TAB arrows) and the indentation indicators on the left, which are all rendered in a Win2D canvas outside of the ScrollViewer within the text control. Additionally, the line number are displayed through a TextBlock living in a Canvas, which is also kept in sync with the text in the same way:

KyjiuIca5M

PR Checklist

Please check if your PR fulfills the following requirements:

Other information

cc. @michael-hawker - would you like me to create a sample/docs page for these two extensions, or is it not needed since they're just two small extensions in an already existing class? Keeping this as a draft PR for now since I'm not sure about this specific point 😄

@ghost
Copy link

ghost commented Apr 3, 2020

Thanks Sergio0694 for opening a Pull Request! The reviewers will test the PR and highlight if there is any conflict or changes required. If the PR is approved we will proceed to merge the pull request 🙌

@michael-hawker
Copy link
Member

@Sergio0694 just going through other issues and saw #1499, can you help me understand how these two things relate?

@Sergio0694
Copy link
Member Author

@michael-hawker Those looks like unrelated extensions, if not for the fact that they (indirectly) both work on a target ScrollViewer at the end of the day. But for instance, those extensions target the ListViewBase type, so they would actually go in another extension class (ListViewBaseExtensions?), and not in the one I'm using here. Also, those are just doing manipulations on the internal ScrollViewer to bring a given item in view, while the ones in this PR instead are about creating a composition expression animation to get an animation that follows the scrolling on the entire targeted ScrollViewer. So yeah, different APIs in use and different use cases. Hope this helps! 😊

@michael-hawker
Copy link
Member

It could be cool to have a sample to show you how you'd setup that sort of syncing as a sample page.

@Sergio0694
Copy link
Member Author

Sergio0694 commented May 12, 2020

Added a sample in the ScrollViewerExample sample page, along with a reference C# snippet. Also modified the API surface to add an additional VisualProperty option, so that users can choose whether to animate through Visual.Translation or Visual.Offset.

For instance, Visual.Translate is enabled by default as it's the one that generally works fine, but there are cases where Visual.Offset might be preferred (eg. when the target items are inside a Canvas).

Let me know if there are any other changes I should do! 😊

@Sergio0694 Sergio0694 marked this pull request as ready for review May 12, 2020 12:50
@michael-hawker michael-hawker added this to the 6.1 milestone May 18, 2020
Copy link
Member

@michael-hawker michael-hawker left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Small nitpick to make the sample shine, but otherwise this is really cool!

@azchohfi I was late on reviewing this before due to all my PC/Internet troubles. This is small and isolated, so seems low-risk to take this late. You good with that?

@ghost
Copy link

ghost commented May 28, 2020

This PR has been marked as "needs attention 👋" and awaiting a response from the team.

@michael-hawker
Copy link
Member

I'll pull this down and re-review now, but I think we'll be good!

@ghost ghost removed the needs attention 👋 label May 29, 2020
@michael-hawker
Copy link
Member

All good, we should Squash and Merge this one again, as there's the weird history coming from @Sergio0694's branches. Hopefully we can get that reset and fixed in future PRs. 😋

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants