RFC: Motion definition & APIs#29958
Conversation
📊 Bundle size report🤖 This report was generated against 5fb68e9bc86c1cbd66249c639a5565fe7a0b22b4 |
|
This pull request is automatically built and testable in CodeSandbox. To see build info of the built libraries, click here or the icon next to each commit SHA. |
Asset size changesSize Auditor did not detect a change in bundle size for any component! Baseline commit: 8b932ca5ae309781abbf07ea48eff1d5581f4439 (build) |
e853103 to
5db5109
Compare
9383b41 to
563b74a
Compare
563b74a to
3f9edf7
Compare
Leaving this comment globally here, as there were no mentions about it, and I was unsure where it belongs within this document (or if it should be in this document or in another RFC). The reason to create a broader solution to handling animations is that Even though it is an advanced usage, there is a need to detect the state of an animation, with the most common one being for "presence" cases. That was the main reason to create the Some examples:
Both mentioned examples can be seen on these examples: Can we think of a way to accommodate that scenario with the new proposed API? In these cases, performance is important but might not be the top priority as it is a fairly advanced use case. Please note that |
07139a0 to
c79b772
Compare
@marcosmoura as we discussed offline, I'm not fully understand the significance of using a state machine in this context. Let me dig into both scenarios we discussed. Sync animation between componentsFrom a React perspective, const motion = useMotion(stateValue);The example provided initiates three animations simultaneously in a function App() {
return (
<>
<Drawer open={stateValue} />
<Content visible={stateValue} />
<Footer visible={stateValue} />
</>
);
}Detect animation stateAs you mentioned, both examples could function without function App() {
const [open, setOpen] = React.useState(false);
const [isUnmounted, setIsUnmounted] = React.useState(!open);
return (
<>
<InlineDrawer
onOpenChange={(_, data) => {
if (data.open) {
setIsUnmounted(true);
}
}}
onTransitionEnd={() => {
/* this is equal to `motion.type === 'unmounted'` */
if (!open) {
setIsUnmounted(false);
}
}}
/>
<div className={mounted ? "x" : "y"} />
</>
);
}Similar handling could be achieved for <Collapse onMotionFinish={() => {}} />
Regarding your point about |
Description
Request for Comments (RFC) proposes the use of the Web Animations API for defining and utilizing motion animations in Fluent UI React components. It discusses various aspects including motion definition, APIs, usage & replacement, performance, and potential issues, while also comparing it with the CSS-based approach.
Preview link (as of 2024-08-15) 🔗