framer-motion 12.27.3 → 12.27.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/cjs/index.js CHANGED
@@ -96,12 +96,16 @@ class PopChildMeasure extends React__namespace.Component {
96
96
  const parentWidth = motionDom.isHTMLElement(parent)
97
97
  ? parent.offsetWidth || 0
98
98
  : 0;
99
+ const parentHeight = motionDom.isHTMLElement(parent)
100
+ ? parent.offsetHeight || 0
101
+ : 0;
99
102
  const size = this.props.sizeRef.current;
100
103
  size.height = element.offsetHeight || 0;
101
104
  size.width = element.offsetWidth || 0;
102
105
  size.top = element.offsetTop;
103
106
  size.left = element.offsetLeft;
104
107
  size.right = parentWidth - size.width - size.left;
108
+ size.bottom = parentHeight - size.height - size.top;
105
109
  }
106
110
  return null;
107
111
  }
@@ -113,7 +117,7 @@ class PopChildMeasure extends React__namespace.Component {
113
117
  return this.props.children;
114
118
  }
115
119
  }
116
- function PopChild({ children, isPresent, anchorX, root }) {
120
+ function PopChild({ children, isPresent, anchorX, anchorY, root }) {
117
121
  const id = React.useId();
118
122
  const ref = React.useRef(null);
119
123
  const size = React.useRef({
@@ -122,6 +126,7 @@ function PopChild({ children, isPresent, anchorX, root }) {
122
126
  top: 0,
123
127
  left: 0,
124
128
  right: 0,
129
+ bottom: 0,
125
130
  });
126
131
  const { nonce } = React.useContext(featureBundle.MotionConfigContext);
127
132
  /**
@@ -141,10 +146,11 @@ function PopChild({ children, isPresent, anchorX, root }) {
141
146
  * styles set via the style prop.
142
147
  */
143
148
  React.useInsertionEffect(() => {
144
- const { width, height, top, left, right } = size.current;
149
+ const { width, height, top, left, right, bottom } = size.current;
145
150
  if (isPresent || !ref.current || !width || !height)
146
151
  return;
147
152
  const x = anchorX === "left" ? `left: ${left}` : `right: ${right}`;
153
+ const y = anchorY === "bottom" ? `bottom: ${bottom}` : `top: ${top}`;
148
154
  ref.current.dataset.motionPopId = id;
149
155
  const style = document.createElement("style");
150
156
  if (nonce)
@@ -158,7 +164,7 @@ function PopChild({ children, isPresent, anchorX, root }) {
158
164
  width: ${width}px !important;
159
165
  height: ${height}px !important;
160
166
  ${x}px !important;
161
- top: ${top}px !important;
167
+ ${y}px !important;
162
168
  }
163
169
  `);
164
170
  }
@@ -171,7 +177,7 @@ function PopChild({ children, isPresent, anchorX, root }) {
171
177
  return (jsxRuntime.jsx(PopChildMeasure, { isPresent: isPresent, childRef: ref, sizeRef: size, children: React__namespace.cloneElement(children, { ref: composedRef }) }));
172
178
  }
173
179
 
174
- const PresenceChild = ({ children, initial, isPresent, onExitComplete, custom, presenceAffectsLayout, mode, anchorX, root }) => {
180
+ const PresenceChild = ({ children, initial, isPresent, onExitComplete, custom, presenceAffectsLayout, mode, anchorX, anchorY, root }) => {
175
181
  const presenceChildren = featureBundle.useConstant(newChildrenMap);
176
182
  const id = React.useId();
177
183
  let isReusedContext = true;
@@ -218,7 +224,7 @@ const PresenceChild = ({ children, initial, isPresent, onExitComplete, custom, p
218
224
  onExitComplete();
219
225
  }, [isPresent]);
220
226
  if (mode === "popLayout") {
221
- children = (jsxRuntime.jsx(PopChild, { isPresent: isPresent, anchorX: anchorX, root: root, children: children }));
227
+ children = (jsxRuntime.jsx(PopChild, { isPresent: isPresent, anchorX: anchorX, anchorY: anchorY, root: root, children: children }));
222
228
  }
223
229
  return (jsxRuntime.jsx(featureBundle.PresenceContext.Provider, { value: context, children: children }));
224
230
  };
@@ -270,7 +276,7 @@ function onlyElements(children) {
270
276
  *
271
277
  * @public
272
278
  */
273
- const AnimatePresence = ({ children, custom, initial = true, onExitComplete, presenceAffectsLayout = true, mode = "sync", propagate = false, anchorX = "left", root }) => {
279
+ const AnimatePresence = ({ children, custom, initial = true, onExitComplete, presenceAffectsLayout = true, mode = "sync", propagate = false, anchorX = "left", anchorY = "top", root }) => {
274
280
  const [isParentPresent, safeToRemove] = featureBundle.usePresence(propagate);
275
281
  /**
276
282
  * Filter any children that aren't ReactElements. We can only track components
@@ -397,7 +403,7 @@ const AnimatePresence = ({ children, custom, initial = true, onExitComplete, pre
397
403
  };
398
404
  return (jsxRuntime.jsx(PresenceChild, { isPresent: isPresent, initial: !isInitialRender.current || initial
399
405
  ? undefined
400
- : false, custom: custom, presenceAffectsLayout: presenceAffectsLayout, mode: mode, root: root, onExitComplete: isPresent ? undefined : onExit, anchorX: anchorX, children: child }, key));
406
+ : false, custom: custom, presenceAffectsLayout: presenceAffectsLayout, mode: mode, root: root, onExitComplete: isPresent ? undefined : onExit, anchorX: anchorX, anchorY: anchorY, children: child }, key));
401
407
  }) }));
402
408
  };
403
409