Function startViewTransition

  • Starts a ViewTransition with additional params. Based on these params, Velvette applies temporary classes to the document element, generates view-transition-name properties and adds temporary styles for the ::view-transition-* pseudo-elements.

    Parameters

    • options: {
          captures: null | {
              [selector: string]: string;
          };
          classes: null | string[];
          styles: null | {
              [key: string]: Partial<CSSStyleDeclaration>;
          };
          update: (() => void | PromiseLike<void>);
      }
      • captures: null | {
            [selector: string]: string;
        }

        A map of captures, see Config#captures

      • classes: null | string[]

        A list of temporary classes to be applied to the document element with a vt- prefix during the course of the transition.

      • styles: null | {
            [key: string]: Partial<CSSStyleDeclaration>;
        }

        A map of styles, see Config#styles

      • update: (() => void | PromiseLike<void>)
          • (): void | PromiseLike<void>
          • The operation that updates the DOM to the new state.

            Returns void | PromiseLike<void>

    Returns null | ViewTransition

    Example

    import {startViewTransition} from "velvette";
    // This will return a ViewTransition, or a null if this browser doesn't support CSS View Transitions.
    startViewTransition({
    async update() {
    // Make actual DOM update
    },

    // This would apply `vt-slide-in` on the root element for the duration of the transition
    classes: ["slide-in"],

    // This would capture any `li.item .box`, and would give it the `view-transition-name`
    // corresponding to "box-" plus its ancestor `li.item`'s id.
    // In addition, it would apply any style with a pseudo that matches '.any-box' to all the
    // captured elements.
    captures: { "li.item[:id] .box": "box-$(id).any-box" }

    // Would apply a blur during the transition, to the transition group generated
    // for any capture that matches the ".any-box".
    styles: {"::view-transition-group(.any-box)": {filter: "blur(1px)"}},
    });

Generated using TypeDoc