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

WIP rough implementation of anchoring and inferred duration for parallel timelines #173

Closed
wants to merge 7 commits into from

Conversation

nickschot
Copy link
Contributor

@nickschot nickschot commented Dec 23, 2022

proof of concept/experimentation for #172

TODO:

  • anchoring (center, end)
  • inferred duration from longest known duration in the parallel timeline
  • sort motion definitions in parallel timeline by presence of duration (be it implicit like a Spring, or explicit)
  • fill behavior (currently inferred durations are "fill")
  • sort by duration as well, so longest is 1st and can be used for fill reference
  • decide about fill overriding defined durations on MotionDefinitions if they're not the longest animation.
  • tests
  • do a 2nd (sort) pass after the springs are resolved (if there are multiple) so their durations are known and can be taken into account

Example with the current API

The border animation will take the duration of the Spring movement animation, since that is the longest animation. The background animation keeps it duration as it has a more specific anchor: center set on it's MotionDefinition. It is centered to the middle of the duration of the entire parallel timeline.

{
      timeline: {
        type: 'parallel',
        anchor: 'fill',
        animations: [
          {
            sprites: keptSprites,
            properties: {
              border: {},
            },
            timing: {
              behavior: new TweenBehavior(),
              duration: 100, // TODO: this is currently overwritten if "fill" is specified on the Timeline.
            },
          },
          {
            sprites: keptSprites,
            properties: {
              translateX: {},
              translateY: {},
              width: {},
              height: {},
            },
            timing: {
              behavior: new SpringBehavior(),
            },
          },
          {
            sprites: keptSprites,
            properties: {
              backgroundColor: {},
            },
            timing: {
              behavior: new TweenBehavior(),
              duration: 1000,
              anchor: 'center',
            },
          },
        ],
      },
    }

@nickschot
Copy link
Contributor Author

nickschot commented Jan 27, 2023

Example with video:

Screen.Recording.2023-01-27.at.15.47.45.mov
timeline: {
        type: 'parallel',
        animations: [
          {
            sprites: keptSprites,
            properties: {
              x: {},
              y: {},
              width: {},
              height: {},
            },
            timing: {
              behavior: new TweenBehavior(),
              duration: 2000,
            },
          },
          {
            sprites: keptSprites,
            properties: {
              backgroundColor: {},
            },
            timing: {
              behavior: new TweenBehavior(),
              duration: 300,
              anchor: 'center',
            },
          },
          {
            sprites: keptSprites,
            properties: {
              border: {},
            },
            timing: {
              behavior: new TweenBehavior(),
              anchor: 'fill',
            },
          },
        ],
      }

Copy link
Contributor

@backspace backspace left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🎉

])
);
});
});
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I appreciate the clarity of these unit tests 🤩

@lukemelia
Copy link
Contributor

Closing due to inactivity

@lukemelia lukemelia closed this Feb 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants