-
Notifications
You must be signed in to change notification settings - Fork 52
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
Revisit SPA API #159
Comments
|
Agreed. Although we need something to distinguish this kind of transition from CSS transitions. We've thrown |
We can use the next rAF after the callback passed to start() returns for the missing touch point : "After the new state is captured, so the developer can target the full set of pseudo elements (eg with WAAPI)". That's actually how the example in the explainer is setup. Also our WPT uses that pattern. |
Is that reliable? Particularly as |
My proposal in the OP doesn't provide a moment to configure the transition with JS before the current state is captured (eg ( Revised proposal: const transition = document.createDocumentTransition();
// Before the DOM change
await transition.prepare(async () => {
// After the current state is captured
await coolFramework.updateDOM();
// After the DOM is modified
});
// After the new state is captured
await transition.finished;
// After the transition is complete This is a relatively minor change from the current API, and maybe closer to @flackr's original proposal. The differences:
|
That's a good question. I suppose if the promise returned by the callback passed to start resolves in the middle of a frame, so we've already dispatched rAF for it, then it means before the render after that. The new proposal looks good. But a slight preference to change the API once we're wrapping up the OT. |
This looks reasonable to me as well. (My initial read of the explainer had the promise resolving at your recommended point as well; Khushal brought up that it was wrong!) Having a .finished promise sounds good, and finally leans us one way on the "singleton or constructor" question - we should have a constructor. |
Fair enough! If we want to do it sooner, we could add In fact, DocumentTransition.prototype.start = async function(...args) {
await this.prepare(...args);
await this.finished;
} |
I think that's a decent plan, we can add |
Latest spec fixes this |
Now seems like a good time to revisit the design of the API.
We need 'touch points' that cover the following:
I think
.start()
was originally intended to fulfill as soon as the new state is captured, but in the current implementation it fulfills once the transition is complete. Either way, it leaves one of the points uncovered.Alternate proposal:
This proposal doesn't allow for JS-added transitions elements. See below for a revised proposal.
API details:
performDocumentTransition
.transition.start
is not called before the callback promise fulfills, it's called automatically (simplifying cases where the developer doesn't need to run code after the start of the transition).transition.start
rejects if the transition cannot be started, or is called after the callback promise settles.performDocumentTransition
rejects if the transition is aborted.The text was updated successfully, but these errors were encountered: