Skip to content

Set "boundaries" for transitions at blocks #1480

Closed
@jacwright

Description

@jacwright

Pulled from #1431 (comment) and opened here as a new issue for further discussion

Note: The following opinions are coming from a view that animations and transitions are most often used in web apps to call attention to changes in a page that is already loaded, and that the area of the page handling the change should be the one defining the transition. For example, the part that deals with changing the entire page in a SPA as you navigate might fade the entire page in (or might choose not to employ any transition), but elements on the page wouldn't fade themselves in unless their data was not loaded at the initial transition, in which case they might fade in after their portion of the data was loaded. Coordinating transitions throughout a page to run together should still be possible for advanced effects but should not be the default.


Addressing this comment #1431 (comment):

Allowing child transitions to run will give fine-grained control and allow more robust use-cases. However, the vast majority of the time this will not be used. I propose the default be childtransition:false and childtransition:true be used instead for those cases when you want the lower animations to run.

I believe transition boundaries should be at the block level with EachBlock, AwaitBlock and IfBlock (including else of course). I don't think it should be at Component because a component with a transition at the top level (not inside a block) would have the expectation that the transition is run when the component is placed within an if/each using the same rules that an HTML element would within that if/each (e.g. skipping the intro/outro when first being added/removed).

The default rule of thumb should be, transition is tied to the if/each nearest it. It should not run (unless explicitly told to do so with an override) when that if/each is first inserted into the DOM or when it is removed, only when the value for the if/each changes and elements are added/removed.

If you want transitions to run across these boundaries then you can use childtransition:true. This would be necessary even if e.g. the outer if didn't have a transition. E.g.

{#if foo}
  <div childtransition:true>
    {#if bar}
      <p transition:fade>
        this will fade in and out when `bar` is toggled, but will
        abruptly disappear when `foo` is toggled
      </p>
    {/if}
  </div>
{/if}

This allows the most expected behavior to be default and prevents confusion that would otherwise prevail when changes in an app (route changes and other large and small changes) cause animations to run unexpectedly.

I believe this is the correct behavior for the majority of web apps and that the directives for childtransition:true and skipintro:false and skipoutro:false will be rarely used and only in special circumstances.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions