Skip to content
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

Expose animation callback in scroll methods #2903

Conversation

jayghoshter
Copy link
Contributor

@jayghoshter jayghoshter commented Jul 8, 2023

Please review the following checklist.

  • Docstrings on all new or modified functions / classes
  • Updated documentation
  • Updated CHANGELOG.md (where appropriate)

Allows using callbacks after the end of the animation (or end of scrolling) in scroll methods in Widget class via the on_complete= keyword argument.

This is my first PR to this project, so I will need some help with any contribution protocol or additional modifications that might be required.

Thanks for the great tool!

Copy link
Collaborator

@willmcgugan willmcgugan left a comment

Choose a reason for hiding this comment

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

Looks good, just one request.

@@ -1760,6 +1765,9 @@ def _scroll_to(
self.scroll_target_y = self.scroll_y = y
scrolled_y = scroll_y != self.scroll_y

if on_complete is not None:
Copy link
Collaborator

Choose a reason for hiding this comment

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

I think you will need self.call_after_refresh(on_complete) here which will allow coroutines to be used, and will ensure the update is called after the screen has updated.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

fixed! Thanks for going through it.

@willmcgugan willmcgugan merged commit 256e8ad into Textualize:main Jul 17, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants