framer-motion 6.3.13 → 6.3.16

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
@@ -472,7 +472,7 @@ var MotionValue = /** @class */ (function () {
472
472
  * This will be replaced by the build step with the latest version number.
473
473
  * When MotionValues are provided to motion components, warn if versions are mixed.
474
474
  */
475
- this.version = "6.3.13";
475
+ this.version = "6.3.16";
476
476
  /**
477
477
  * Duration, in milliseconds, since last updating frame.
478
478
  *
@@ -1830,7 +1830,7 @@ var globalProjectionState = {
1830
1830
  hasEverUpdated: false,
1831
1831
  };
1832
1832
  function createProjectionNode(_a) {
1833
- var attachResizeListener = _a.attachResizeListener, defaultParent = _a.defaultParent, measureScroll = _a.measureScroll, resetTransform = _a.resetTransform;
1833
+ var attachResizeListener = _a.attachResizeListener, defaultParent = _a.defaultParent, measureScroll = _a.measureScroll, checkIsScrollRoot = _a.checkIsScrollRoot, resetTransform = _a.resetTransform;
1834
1834
  return /** @class */ (function () {
1835
1835
  function ProjectionNode(id, latestValues, parent) {
1836
1836
  var _this = this;
@@ -2233,6 +2233,7 @@ function createProjectionNode(_a) {
2233
2233
  };
2234
2234
  ProjectionNode.prototype.updateScroll = function () {
2235
2235
  if (this.options.layoutScroll && this.instance) {
2236
+ this.isScrollRoot = checkIsScrollRoot(this.instance);
2236
2237
  this.scroll = measureScroll(this.instance);
2237
2238
  }
2238
2239
  };
@@ -2276,8 +2277,24 @@ function createProjectionNode(_a) {
2276
2277
  */
2277
2278
  for (var i = 0; i < this.path.length; i++) {
2278
2279
  var node = this.path[i];
2279
- var scroll_1 = node.scroll, options = node.options;
2280
+ var scroll_1 = node.scroll, options = node.options, isScrollRoot = node.isScrollRoot;
2280
2281
  if (node !== this.root && scroll_1 && options.layoutScroll) {
2282
+ /**
2283
+ * If this is a new scroll root, we want to remove all previous scrolls
2284
+ * from the viewport box.
2285
+ */
2286
+ if (isScrollRoot) {
2287
+ copyBoxInto(boxWithoutScroll, box);
2288
+ var rootScroll = this.root.scroll;
2289
+ /**
2290
+ * Undo the application of page scroll that was originally added
2291
+ * to the measured bounding box.
2292
+ */
2293
+ if (rootScroll) {
2294
+ translateAxis(boxWithoutScroll.x, -rootScroll.x);
2295
+ translateAxis(boxWithoutScroll.y, -rootScroll.y);
2296
+ }
2297
+ }
2281
2298
  translateAxis(boxWithoutScroll.x, scroll_1.x);
2282
2299
  translateAxis(boxWithoutScroll.y, scroll_1.y);
2283
2300
  }
@@ -3002,7 +3019,7 @@ function useProjectionId() {
3002
3019
  var LayoutGroupContext = React.createContext({});
3003
3020
 
3004
3021
  /**
3005
- * @internal
3022
+ * Internal, exported only for usage in Framer
3006
3023
  */
3007
3024
  var SwitchLayoutGroupContext = React.createContext({});
3008
3025
 
@@ -5966,7 +5983,7 @@ function updateMotionValuesFromProps(element, next, prev) {
5966
5983
  * and warn against mismatches.
5967
5984
  */
5968
5985
  if (process.env.NODE_ENV === "development") {
5969
- warnOnce(nextValue.version === "6.3.13", "Attempting to mix Framer Motion versions ".concat(nextValue.version, " with 6.3.13 may not work as expected."));
5986
+ warnOnce(nextValue.version === "6.3.16", "Attempting to mix Framer Motion versions ".concat(nextValue.version, " with 6.3.16 may not work as expected."));
5970
5987
  }
5971
5988
  }
5972
5989
  else if (isMotionValue(prevValue)) {
@@ -7080,6 +7097,7 @@ var DocumentProjectionNode = createProjectionNode({
7080
7097
  x: document.documentElement.scrollLeft || document.body.scrollLeft,
7081
7098
  y: document.documentElement.scrollTop || document.body.scrollTop,
7082
7099
  }); },
7100
+ checkIsScrollRoot: function () { return true; },
7083
7101
  });
7084
7102
 
7085
7103
  var rootProjectionNode = {
@@ -7102,6 +7120,9 @@ var HTMLProjectionNode = createProjectionNode({
7102
7120
  resetTransform: function (instance, value) {
7103
7121
  instance.style.transform = value !== null && value !== void 0 ? value : "none";
7104
7122
  },
7123
+ checkIsScrollRoot: function (instance) {
7124
+ return Boolean(window.getComputedStyle(instance).position === "fixed");
7125
+ },
7105
7126
  });
7106
7127
 
7107
7128
  var featureBundle = tslib.__assign(tslib.__assign(tslib.__assign(tslib.__assign({}, animations), gestureAnimations), drag), layoutFeatures);
@@ -1,7 +1,7 @@
1
1
  import { createContext } from 'react';
2
2
 
3
3
  /**
4
- * @internal
4
+ * Internal, exported only for usage in Framer
5
5
  */
6
6
  var SwitchLayoutGroupContext = createContext({});
7
7
 
@@ -7,6 +7,7 @@ var DocumentProjectionNode = createProjectionNode({
7
7
  x: document.documentElement.scrollLeft || document.body.scrollLeft,
8
8
  y: document.documentElement.scrollTop || document.body.scrollTop,
9
9
  }); },
10
+ checkIsScrollRoot: function () { return true; },
10
11
  });
11
12
 
12
13
  export { DocumentProjectionNode };
@@ -21,6 +21,9 @@ var HTMLProjectionNode = createProjectionNode({
21
21
  resetTransform: function (instance, value) {
22
22
  instance.style.transform = value !== null && value !== void 0 ? value : "none";
23
23
  },
24
+ checkIsScrollRoot: function (instance) {
25
+ return Boolean(window.getComputedStyle(instance).position === "fixed");
26
+ },
24
27
  });
25
28
 
26
29
  export { HTMLProjectionNode, rootProjectionNode };
@@ -43,7 +43,7 @@ var globalProjectionState = {
43
43
  hasEverUpdated: false,
44
44
  };
45
45
  function createProjectionNode(_a) {
46
- var attachResizeListener = _a.attachResizeListener, defaultParent = _a.defaultParent, measureScroll = _a.measureScroll, resetTransform = _a.resetTransform;
46
+ var attachResizeListener = _a.attachResizeListener, defaultParent = _a.defaultParent, measureScroll = _a.measureScroll, checkIsScrollRoot = _a.checkIsScrollRoot, resetTransform = _a.resetTransform;
47
47
  return /** @class */ (function () {
48
48
  function ProjectionNode(id, latestValues, parent) {
49
49
  var _this = this;
@@ -446,6 +446,7 @@ function createProjectionNode(_a) {
446
446
  };
447
447
  ProjectionNode.prototype.updateScroll = function () {
448
448
  if (this.options.layoutScroll && this.instance) {
449
+ this.isScrollRoot = checkIsScrollRoot(this.instance);
449
450
  this.scroll = measureScroll(this.instance);
450
451
  }
451
452
  };
@@ -489,8 +490,24 @@ function createProjectionNode(_a) {
489
490
  */
490
491
  for (var i = 0; i < this.path.length; i++) {
491
492
  var node = this.path[i];
492
- var scroll_1 = node.scroll, options = node.options;
493
+ var scroll_1 = node.scroll, options = node.options, isScrollRoot = node.isScrollRoot;
493
494
  if (node !== this.root && scroll_1 && options.layoutScroll) {
495
+ /**
496
+ * If this is a new scroll root, we want to remove all previous scrolls
497
+ * from the viewport box.
498
+ */
499
+ if (isScrollRoot) {
500
+ copyBoxInto(boxWithoutScroll, box);
501
+ var rootScroll = this.root.scroll;
502
+ /**
503
+ * Undo the application of page scroll that was originally added
504
+ * to the measured bounding box.
505
+ */
506
+ if (rootScroll) {
507
+ translateAxis(boxWithoutScroll.x, -rootScroll.x);
508
+ translateAxis(boxWithoutScroll.y, -rootScroll.y);
509
+ }
510
+ }
494
511
  translateAxis(boxWithoutScroll.x, scroll_1.x);
495
512
  translateAxis(boxWithoutScroll.y, scroll_1.y);
496
513
  }
@@ -18,7 +18,7 @@ function updateMotionValuesFromProps(element, next, prev) {
18
18
  * and warn against mismatches.
19
19
  */
20
20
  if (process.env.NODE_ENV === "development") {
21
- warnOnce(nextValue.version === "6.3.13", "Attempting to mix Framer Motion versions ".concat(nextValue.version, " with 6.3.13 may not work as expected."));
21
+ warnOnce(nextValue.version === "6.3.16", "Attempting to mix Framer Motion versions ".concat(nextValue.version, " with 6.3.16 may not work as expected."));
22
22
  }
23
23
  }
24
24
  else if (isMotionValue(prevValue)) {
@@ -25,7 +25,7 @@ var MotionValue = /** @class */ (function () {
25
25
  * This will be replaced by the build step with the latest version number.
26
26
  * When MotionValues are provided to motion components, warn if versions are mixed.
27
27
  */
28
- this.version = "6.3.13";
28
+ this.version = "6.3.16";
29
29
  /**
30
30
  * Duration, in milliseconds, since last updating frame.
31
31
  *
@@ -1706,7 +1706,7 @@
1706
1706
  * This will be replaced by the build step with the latest version number.
1707
1707
  * When MotionValues are provided to motion components, warn if versions are mixed.
1708
1708
  */
1709
- this.version = "6.3.13";
1709
+ this.version = "6.3.16";
1710
1710
  /**
1711
1711
  * Duration, in milliseconds, since last updating frame.
1712
1712
  *
@@ -3064,7 +3064,7 @@
3064
3064
  hasEverUpdated: false,
3065
3065
  };
3066
3066
  function createProjectionNode(_a) {
3067
- var attachResizeListener = _a.attachResizeListener, defaultParent = _a.defaultParent, measureScroll = _a.measureScroll, resetTransform = _a.resetTransform;
3067
+ var attachResizeListener = _a.attachResizeListener, defaultParent = _a.defaultParent, measureScroll = _a.measureScroll, checkIsScrollRoot = _a.checkIsScrollRoot, resetTransform = _a.resetTransform;
3068
3068
  return /** @class */ (function () {
3069
3069
  function ProjectionNode(id, latestValues, parent) {
3070
3070
  var _this = this;
@@ -3467,6 +3467,7 @@
3467
3467
  };
3468
3468
  ProjectionNode.prototype.updateScroll = function () {
3469
3469
  if (this.options.layoutScroll && this.instance) {
3470
+ this.isScrollRoot = checkIsScrollRoot(this.instance);
3470
3471
  this.scroll = measureScroll(this.instance);
3471
3472
  }
3472
3473
  };
@@ -3510,8 +3511,24 @@
3510
3511
  */
3511
3512
  for (var i = 0; i < this.path.length; i++) {
3512
3513
  var node = this.path[i];
3513
- var scroll_1 = node.scroll, options = node.options;
3514
+ var scroll_1 = node.scroll, options = node.options, isScrollRoot = node.isScrollRoot;
3514
3515
  if (node !== this.root && scroll_1 && options.layoutScroll) {
3516
+ /**
3517
+ * If this is a new scroll root, we want to remove all previous scrolls
3518
+ * from the viewport box.
3519
+ */
3520
+ if (isScrollRoot) {
3521
+ copyBoxInto(boxWithoutScroll, box);
3522
+ var rootScroll = this.root.scroll;
3523
+ /**
3524
+ * Undo the application of page scroll that was originally added
3525
+ * to the measured bounding box.
3526
+ */
3527
+ if (rootScroll) {
3528
+ translateAxis(boxWithoutScroll.x, -rootScroll.x);
3529
+ translateAxis(boxWithoutScroll.y, -rootScroll.y);
3530
+ }
3531
+ }
3515
3532
  translateAxis(boxWithoutScroll.x, scroll_1.x);
3516
3533
  translateAxis(boxWithoutScroll.y, scroll_1.y);
3517
3534
  }
@@ -4236,7 +4253,7 @@
4236
4253
  var LayoutGroupContext = React.createContext({});
4237
4254
 
4238
4255
  /**
4239
- * @internal
4256
+ * Internal, exported only for usage in Framer
4240
4257
  */
4241
4258
  var SwitchLayoutGroupContext = React.createContext({});
4242
4259
 
@@ -7200,7 +7217,7 @@
7200
7217
  * and warn against mismatches.
7201
7218
  */
7202
7219
  {
7203
- warnOnce(nextValue.version === "6.3.13", "Attempting to mix Framer Motion versions ".concat(nextValue.version, " with 6.3.13 may not work as expected."));
7220
+ warnOnce(nextValue.version === "6.3.16", "Attempting to mix Framer Motion versions ".concat(nextValue.version, " with 6.3.16 may not work as expected."));
7204
7221
  }
7205
7222
  }
7206
7223
  else if (isMotionValue(prevValue)) {
@@ -8314,6 +8331,7 @@
8314
8331
  x: document.documentElement.scrollLeft || document.body.scrollLeft,
8315
8332
  y: document.documentElement.scrollTop || document.body.scrollTop,
8316
8333
  }); },
8334
+ checkIsScrollRoot: function () { return true; },
8317
8335
  });
8318
8336
 
8319
8337
  var rootProjectionNode = {
@@ -8336,6 +8354,9 @@
8336
8354
  resetTransform: function (instance, value) {
8337
8355
  instance.style.transform = value !== null && value !== void 0 ? value : "none";
8338
8356
  },
8357
+ checkIsScrollRoot: function (instance) {
8358
+ return Boolean(window.getComputedStyle(instance).position === "fixed");
8359
+ },
8339
8360
  });
8340
8361
 
8341
8362
  var featureBundle = __assign(__assign(__assign(__assign({}, animations), gestureAnimations), drag), layoutFeatures);