Skip to content
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

[css-view-transitions-2] Allow changing types using JS after (MPA) transition started? #9542

Closed
noamr opened this issue Oct 31, 2023 · 3 comments · Fixed by #10072
Closed
Labels
css-view-transitions-2 View Transitions; New feature requests Needs Edits

Comments

@noamr
Copy link
Collaborator

noamr commented Oct 31, 2023

Currently we're only allowing to set the transition types at startViewTransition, and they can get changed when revealing the new document in a cross-document view transition.

But perhaps we can allow the author to read or change the types programmatically, as a DOMTokenList on the VT object?
Something like this:

document.addEventListener("pagereveal", event => {
  const {viewTransition} = event;
  const hasSlideIn = viewTransition.typeList.has("slide-in");
  if (heroImage.loaded) {
     viewTransition.typeList.toggle("expand-hero", true);
  }
});

Note that this is possible to do today using the CSSOM, but not dynamically while the VT is already running.

@noamr
Copy link
Collaborator Author

noamr commented Mar 5, 2024

Proposed resolution from internal sync: have a typeList attribute in a ViewTransition object that can mutate types at any point.

@noamr noamr added the Agenda+ label Mar 5, 2024
@css-meeting-bot
Copy link
Member

The CSS Working Group just discussed [css-view-transitions-2] Allow changing `types` using JS after (MPA) transition started?, and agreed to the following:

  • RESOLVED: Add a mutable .typeList to the VT object
The full IRC log of that discussion <TabAtkins> noamr: These issues are related, and not very big, just finishing up
<TabAtkins> noamr: We want to make types mutable.
<TabAtkins> noamr: Refresher, types let you define a "masterclass" for the whoel transition. Set a type when you start the VT, can pass types to the function, then can select based on that type with the VT pseudos
<TabAtkins> noamr: So you can use several transition styles in the same page without having to manually swap them out with JS
<TabAtkins> noamr: So we wanted to allow changing those types on the VT object.
<TabAtkins> noamr: Proposed resolution has details, but it's to have .typeList on the VT object, a DOMTokenList like .classList
<TabAtkins> noamr: And it works just like changing classes
<astearns> q+
<TabAtkins> noamr: We foudn this useful for cross-document VTs
<TabAtkins> noamr: sometimes, only after you get the reveal event you know what the type is gonna be
<TabAtkins> noamr: maybe some image you expected has or hasn't loaded in the new page, etc
<TabAtkins> noamr: So changing the types seems flexible enough
<TabAtkins> astearns: when you change the typelist in JS, it will no longer match what was specified in your CSS for the VT
<TabAtkins> astearns: I'm guessing that's okay and intended, because as the VT is going you maynot have access to that CSS anymore
<khush> q?
<astearns> ack astearns
<TabAtkins> noamr: Right. First for SPA VTs you define the types in JS anyway. For cross-doc tho, you're correct
<TabAtkins> noamr: We read the VT from CSS in exactly two places - when you're ready to leave the old doc, and ready to present the new doc.
<bramus> q+
<TabAtkins> noamr: In these cases we'll read the CSS, then in the events you can change the types via the VT object
<astearns> ack bramus
<TabAtkins> bramus: Like this in general.
<TabAtkins> bramus: Maybe we should also rename the types property that we pass into the VT starting function
<TabAtkins> bramus: it's "types" in one function, "typeList" on the VT object
<TabAtkins> noamr: Yeah, it's called "type" when you start the VT, but there it's an array, here it's a token list. This is equivalent to "class" and "classLIst"
<TabAtkins> bramus: Ah then there's a typo in the spec saying "types"
<TabAtkins> noamr: Ah I'll fix
<TabAtkins> astearns: proposed resolution: mutable .typeList on the VT object. Objections?
<TabAtkins> RESOLVED: Add a mutable .typeList to the VT object

@bramus
Copy link
Contributor

bramus commented Mar 13, 2024

Follow-up issue about the type argument which was brought up in the meeting: #10070

noamr added a commit to noamr/csswg-drafts that referenced this issue Mar 13, 2024
- Make types mutable using ViewTransition.typeList
w3c#9542 (comment)

- Separate `:active-view-transition` and `:active-view-transition-type`
See w3c#9972 (comment)

- Add notes about types being bound to one document
See w3c#9526 (comment)

Closes w3c#9972
Closes w3c#9542
Closes w3c#9526
Closes w3c#9626
@noamr noamr closed this as completed in bd11f28 Mar 14, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
css-view-transitions-2 View Transitions; New feature requests Needs Edits
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants