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

Feat/animate grid #6046

Merged
merged 15 commits into from
Jul 9, 2024
Merged

Feat/animate grid #6046

merged 15 commits into from
Jul 9, 2024

Conversation

ruggi
Copy link
Contributor

@ruggi ruggi commented Jul 9, 2024

Problem:

When rearranging grid elements, they should animate along the X/Y axii to indicate the completed movement.
Moreover, we don't have a way to animate rendered canvas elements.

Fix:

This PR introduces a way to animate canvas elements programmatically, without having to inject anything inside the rendered components themselves. After doing that, the PR uses the new logic to animate the grid rearrange as a first test subject.

The goal is to be able to arbitrarily animate canvas elements using the same framer motion API we use elsewhere, explicitly. In order to avoid manipulating the rendered elements, the targeting capabilities of useAnimate are used here.

  1. Create the animation scope and animation function with useAnimate
  2. Connect the scope with the DesignPanelRoot component
  3. Store the animation function in a new AnimationContext context
  4. useCanvasAnimation can now be used to target specific canvas elements and animate them, selecting them from the DOM by their data-uid prop
  5. 🎈
Untitled.mov

Copy link
Contributor

github-actions bot commented Jul 9, 2024

Try me

Copy link

relativeci bot commented Jul 9, 2024

#13296 Bundle Size — 62.6MiB (+0.15%).

a7bdc20(current) vs 6339ece master#13292(baseline)

Warning

Bundle contains 51 duplicate packages – View duplicate packages

Bundle metrics  Change 4 changes Regression 1 regression
                 Current
#13296
     Baseline
#13292
Regression  Initial JS 45.66MiB(+0.2%) 45.57MiB
No change  Initial CSS 0B 0B
Change  Cache Invalidation 23.87% 21.61%
No change  Chunks 30 30
No change  Assets 33 33
Change  Modules 4349(+0.6%) 4323
No change  Duplicate Modules 524 524
Change  Duplicate Code 31.72%(-0.06%) 31.74%
No change  Packages 450 450
No change  Duplicate Packages 51 51
Bundle size by type  Change 2 changes Regression 1 regression Improvement 1 improvement
                 Current
#13296
     Baseline
#13292
Regression  JS 62.59MiB (+0.15%) 62.5MiB
Improvement  HTML 11.16KiB (-0.33%) 11.2KiB

Bundle analysis reportBranch feat/animate-gridProject dashboard

@liady
Copy link
Contributor

liady commented Jul 9, 2024

this is super slick. well done 👏

@@ -1479,7 +1479,8 @@ describe('record variable values', () => {
})

describe('specialSizeMeasurements.globalFrameWithTextContent', () => {
it('includes the size of a contained text node', async () => {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

cc @seanparsons for future reference

ruggi added 3 commits July 9, 2024 15:44
# Conflicts:
#	editor/src/core/model/element-metadata.spec.browser2.tsx
@@ -516,7 +519,7 @@ export const EditorComponentInner = React.memo((props: EditorProps) => {
overflowX: 'hidden',
}}
>
<DesignPanelRoot />
<DesignPanelRoot animationScope={props.animationScope} />
Copy link
Contributor

Choose a reason for hiding this comment

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

why the prop drilling here? couldn't / shouldn't this be in a context? is props.animationScope referentially stable?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

what about this b60e41e ?

Copy link
Contributor

@balazsbajorics balazsbajorics left a comment

Choose a reason for hiding this comment

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

👨‍🎨

@ruggi ruggi merged commit 5937af1 into master Jul 9, 2024
13 checks passed
@ruggi ruggi deleted the feat/animate-grid branch July 9, 2024 14:46
liady pushed a commit that referenced this pull request Dec 13, 2024
**Problem:**

When rearranging grid elements, they should animate along the X/Y axii
to indicate the completed movement.
Moreover, we don't have a way to animate rendered canvas elements.

**Fix:**

This PR introduces a way to animate canvas elements programmatically,
without having to inject anything inside the rendered components
themselves. After doing that, the PR uses the new logic to animate the
grid rearrange as a first test subject.

The goal is to be able to arbitrarily animate canvas elements using the
same framer motion API we use elsewhere, explicitly. In order to avoid
manipulating the rendered elements, the targeting capabilities of
`useAnimate` are used here.

1. Create the animation scope and animation function with `useAnimate` 
2. Connect the scope with the `DesignPanelRoot` component
3. Store the animation function in a new `AnimationContext` context
4. `useCanvasAnimation` can now be used to target specific canvas
elements and animate them, selecting them from the DOM by their
`data-uid` prop
5. 🎈 



https://github.com/concrete-utopia/utopia/assets/1081051/ab70b016-a91b-47f8-95ec-bec00bdca838
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.

4 participants