You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardexpand all lines: src/index.js
+75-12
Original file line number
Diff line number
Diff line change
@@ -7,14 +7,40 @@ import { start } from "./transition.js";
7
7
import{init}from"./nav.js";
8
8
9
9
/**
10
+
* Starts a {@link https://developer.mozilla.org/en-US/docs/Web/API/ViewTransition ViewTransition} with
11
+
* additional params. Based on these params, Velvette applies temporary classes to the {@link https://developer.mozilla.org/en-US/docs/Web/HTML/Element/html document element},
* and adds temporary styles for {@link https://developer.mozilla.org/en-US/docs/Web/API/View_Transitions_API#the_view_transition_process the `::view-transition-*` pseudo-elements}.
* @param {() => void | Promise<void>} options.update The operation that updates the DOM to the new state.
17
+
* @param {string[]?} options.classes A list of temporary classes to be applied to the document element with a `vt-` prefix during the course of the transition.
18
+
* @param {{[key: string]: Partial<CSSStyleDeclaration>}?} options.styles A map of styles, see {@link Config#styles}
19
+
* @param {{[selector: string]: string}?} options.captures A map of captures, see {@link Config#captures}
16
20
*
17
21
* @returns {ViewTransition | null}
22
+
*
23
+
* @example
24
+
* import {startViewTransition} from "velvette";
25
+
* // This will return a ViewTransition, or a null if this browser doesn't support CSS View Transitions.
26
+
* startViewTransition({
27
+
* async update() {
28
+
* // Make actual DOM update
29
+
* },
30
+
*
31
+
* // This would apply `vt-slide-in` on the root element for the duration of the transition
32
+
* classes: ["slide-in"],
33
+
*
34
+
* // This would capture any `li.item .box`, and would give it the `view-transition-name`
35
+
* // corresponding to "box-" plus its ancestor `li.item`'s id.
36
+
* // In addition, it would apply any style with a pseudo that matches '.any-box' to all the
@@ -46,20 +72,43 @@ export class VelvetteEvent extends Event {
46
72
}
47
73
}
48
74
75
+
/**
76
+
* Constructs an object that takes a {@link Config} param and can then perform view transitions
77
+
* based on navigations. There are 3 ways to invoke a navigation-based transition:
78
+
*
79
+
* - Programatically, via {@link Velvette#startNavigation Velvette.startNavigation}
80
+
* - Same-document: by {@link Velvette#intercept intercepting} a navigation using the {@link https://developer.mozilla.org/en-US/docs/Web/API/Navigation_API Navigation API}
81
+
* - Cross-document: by attaching to the window's events {@link Velvette#crossDocument Velvette.crossDocument}. Note that this doesn't work in stable browsers yet.
82
+
*
83
+
* See {@link Config} for the different configuration options.
84
+
*/
49
85
exportclassVelvette{
50
86
#internal;
51
-
/** @param {Config} config */
87
+
/** @param {Config} config The configuration object that defines how to handle each navigation */
0 commit comments