Skip to content

Pausable rendering#28

Closed
domchristie wants to merge 1 commit intohotwired:mainfrom
domchristie:await_render
Closed

Pausable rendering#28
domchristie wants to merge 1 commit intohotwired:mainfrom
domchristie:await_render

Conversation

@domchristie
Copy link
Copy Markdown
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
Copy Markdown

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
Copy Markdown

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

@weaverryan
Copy link
Copy Markdown

@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
Copy Markdown

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

Pinging @dhh !

@dhh
Copy link
Copy Markdown
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
Copy Markdown
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