Skip to content

[css-view-transitions-2] Automatically start view transitions for <dialog>, Popover, etc. #8083

@mfreed7

Description

@mfreed7

This possibility was raised in whatwg/html#7785 (comment). The idea is that perhaps a ViewTransition could be automatically started, with appropriate modifications to existing algorithms, for <dialog>, Popover, and perhaps even any element moving to/from display:none.

Option 1: content attribute

One option would be to add a content attribute that confers this behavior:

<dialog autostartatransition>
  When shown/closed, a View Transition will start
</dialog>

When that attribute is present, existing algorithms such as showModal() would be modified to 1) start a ViewTransition, then 2) run existing steps for the algorithm that show/hide the element.

The content attribute approach would seem to work for most element types, including perhaps even when <div autostartatransition> becomes <div style="display:none" autostartatransition>. All of these would require thought about how to incorporate this behavior into all of the relevant spec algorithms.

Option 2: individual APIs

Another alternative would be to modify existing APIs:

myDialog.show({autostartatransition: true});
myDialog.showModal({autostartatransition: true});
myDialog.close({autostartatransition: true});
myPopover.showPopover({autostartatransition: true});
myPopover.hidePopover({autostartatransition: true});

I'm not sure how that would look for the plain <div style="display:none"> example.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions