LayoutId shared element transitions across nested trees – missing constraint
0 reputation · 25 Aug 2024, 03:21 UTC
Goal
Use Framer Motion’s layoutId to animate a component that appears in two different parts of the component tree, potentially spanning separate React contexts or deeply nested DOM hierarchies.
Uncertainty
While layoutId is documented to treat elements with the same ID as a shared element, the behavior when the DOM structure changes dramatically (e.g., a component moves from one context to another or is wrapped in additional layers) is not fully specified. This can lead to unexpected jumpy transitions or incorrect bounding‑box calculations.
Specific Questions
- What constraints should be applied to the DOM hierarchy when using
layoutIdacross different component trees to ensure smooth transitions? - How does deep nesting or context boundaries affect the calculation of bounding boxes in layout animations?
- Is there a recommended approach to mitigate performance overhead when using
layoutIdon many elements?