Private
#internalPrivate
Note: This is experimental and only work in Chrome canary with some flags. Attaches to the document's events and enables the view-transition config for cross-document navigations.
A NavigateEvent
const velvette = new Velvette(config);
window.navigation.addEventListener("navigate", event => {
if (shouldInterceptEvent(event)) {
// This would potentially start a transition based on the configuration.
velvette.intercept(event, {
async handler() {
// Make actual DOM change
}
});
});
}
The previous URL of the navigation
The type of navigation (push/replace/reload/traverse)
The next URL of the navigation
If this is a traverse
navigation, the delta. E.g. -1 is "back".
The operation that updates the DOM based on the navigation.
const velvette = new Velvette(config);
link.addEventListener("click", event => {
velvette.startNavigation({
from: document.URL,
to: event.target.href,
navigationType: "push",
}, () => {
// Make actual DOM change.
});
});
Generated using TypeDoc
Constructs an object that takes a Config param and can then perform view transitions based on navigations. There are 3 ways to invoke a navigation-based transition:
See Config for the different configuration options.