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

Staggered transitions #545

Open
Rich-Harris opened this issue May 1, 2017 · 2 comments
Open

Staggered transitions #545

Rich-Harris opened this issue May 1, 2017 · 2 comments

Comments

@Rich-Harris
Copy link
Member

A common requirement is to stagger transitions:

barchart

In the GIF, it's been faked with an index and a delay:

<g class='bars'>
  {{#each points as point, i}}
    {{#if show}}
      <rect
        in:grow='{delay: i*200}'
        out:fade
        x='{{xScale(i) + 2}}'
        y='{{yScale(point.birthrate)}}'
        width='{{ barWidth - 4 }}'
        height='{{ height - padding.bottom - yScale(point.birthrate) }}'
        ></rect>
    {{/if}}
  {{/each}}
</g>

But that doesn't work well if new items are added, since their indices will start at n rather than 0.

If the intro is aborted (show becomes false, in the example above), if we have staggered outros then we probably want to a) reverse the stagger (last-in-first-out), and b) ignore any intro transitions that haven't yet started, so that the subject of the most recently started intro transition starts to outro immediately. That would be very hard to do with delays.

Not sure what that would look like. It probably needs to be a separate directive — something like this (means 'start each intro transition 200ms after the last one, and each outro transition 50ms after the last one but go backwards'):

<rect
  in:grow
  stagger:in=200
  stagger:out=-50
  ...

Something else you might want to do is supply a fraction rather than an absolute number. This variant means 'start each intro transition once the previous one is 80% done, but use a fixed 50ms interval for outros':

<rect
  in:grow
  stagger:in=0.8
  stagger:out=-50ms
  ...

Any thoughts?

@stale
Copy link

stale bot commented Dec 25, 2021

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@Ayfri

This comment was marked as duplicate.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants