-
Notifications
You must be signed in to change notification settings - Fork 746
Closed
Labels
css-view-transitions-2View Transitions; New feature requestsView Transitions; New feature requests
Description
View Transition API needs to provide an event on the old Document to enable customization of the transition based on the URL for the new Document and the current Document state. For example, the Document could have changed from user interaction after its first load.
The proposed IDL is as follows:
[Exposed=Window]
interface ViewTransitionBeforeCaptureEvent : Event {
// The URL being navigated to, after resolving server-side redirects.
readonly attribute USVString url;
// Opaque contextual information passed to the new Document.
// This must be a serializable object : https://developer.mozilla.org/en-US/docs/Glossary/Serializable_object.
attribute any context;
};
The following is sample code using this event:
document.addEventListener("viewtransitionbeforecapture", (event) => {
// Cancel the transition (based on new URL) if needed.
if (shouldNotTransition(event.toURL)) {
event.preventDefault();
return;
}
// Set up names on elements based on the new URL.
if (shouldTagThumbnail(event.toURL)) {
thumbnail.style.viewTransitionName = "full-embed";
}
// Add opaque contextual information to share with the new Document.
event.context = createTransitionContext(event.url);
});
Metadata
Metadata
Assignees
Labels
css-view-transitions-2View Transitions; New feature requestsView Transitions; New feature requests