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

Pausable rendering #28

Closed
wants to merge 1 commit into from
Closed

Conversation

domchristie
Copy link
Contributor

@domchristie domchristie commented Dec 23, 2020

Just like turbo:before-visit, this pull request makes the turbo:before-render event cancellable with preventDefault. Additionally it adds a render method to the event to let the render process resolve (using Promises). This effectively makes rendering pausable; useful for waiting for exit animations, and could open the door to custom renderers e.g. DOM diffing. A basic example might look like:

addEventListener('turbo:before-render', async function (event) {
  event.preventDefault()
  await animateOut()
  event.detail.render()
})

Here's a demo of some basic animation possibilities: https://laser-crawling-chanter.glitch.me/ (View source)

This pull request also adds the Visit's action to the event detail, making it possible to change the behaviour depending on whether it's an advance or restore.

If there's interest, I could do similar features for streams/frames + add documentation.

There are a few old Turbolinks issues that make reference to something like this:

@rainerborene
Copy link

This is the only thing stopping me from using turbo at my company. Just waiting for @sstephenson bless on this PR 😅

@seanpdoyle seanpdoyle added the enhancement New feature or request label Apr 1, 2021
@daviddeutsch
Copy link

Apologies for the additional bump, but this has been in waiting since January and would be an amazing addition.

@weaverryan
Copy link

@domchristie i don’t know the status of who would merge things at the moment, but, to help, perhaps you could resolve the conflicts?

And, while we’re waiting, is there any decent workaround?

Thanks!

@daviddeutsch
Copy link

Seems like this is orphaned after the recent changes at basecamp.

Pinging @dhh !

@dhh
Copy link
Member

dhh commented Jun 19, 2021

Happy to see this carried forward, if someone else wants to pickup the PR.

@dhh dhh mentioned this pull request Jun 19, 2021
@kirillplatonov
Copy link
Contributor

@dhh The feature looks great. I will prepare an updated PR for it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Development

Successfully merging this pull request may close these issues.

8 participants