framer-motion 8.0.0 → 8.0.2

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
@@ -2065,7 +2065,7 @@ class MotionValue {
2065
2065
  * This will be replaced by the build step with the latest version number.
2066
2066
  * When MotionValues are provided to motion components, warn if versions are mixed.
2067
2067
  */
2068
- this.version = "8.0.0";
2068
+ this.version = "8.0.2";
2069
2069
  /**
2070
2070
  * Duration, in milliseconds, since last updating frame.
2071
2071
  *
@@ -3590,7 +3590,7 @@ function animateStyle(element, valueName, keyframes, { delay = 0, duration, repe
3590
3590
  */
3591
3591
  const sampleDelta = 10; //ms
3592
3592
  function createAcceleratedAnimation(value, valueName, { onUpdate, onComplete, ...options }) {
3593
- let { keyframes, duration = 0.3, elapsed = 0, ease } = options;
3593
+ let { keyframes, duration = 300, elapsed = 0, ease } = options;
3594
3594
  /**
3595
3595
  * If this animation needs pre-generated keyframes then generate.
3596
3596
  */
@@ -3845,7 +3845,7 @@ const isAnimatable = (key, value) => {
3845
3845
  * This filters out orchestration options and returns true
3846
3846
  * if any options are left.
3847
3847
  */
3848
- function isTransitionDefined({ when, delay: _delay, delayChildren, staggerChildren, staggerDirection, repeat, repeatType, repeatDelay, from, ...transition }) {
3848
+ function isTransitionDefined({ when, delay: _delay, delayChildren, staggerChildren, staggerDirection, repeat, repeatType, repeatDelay, from, elapsed, ...transition }) {
3849
3849
  return !!Object.keys(transition).length;
3850
3850
  }
3851
3851
  function isZero(value) {
@@ -4570,12 +4570,16 @@ class PanSession {
4570
4570
  onMove && onMove(this.lastMoveEvent, info);
4571
4571
  };
4572
4572
  this.handlePointerMove = (event, info) => {
4573
+ if (!isPrimaryPointer(event))
4574
+ return;
4573
4575
  this.lastMoveEvent = event;
4574
4576
  this.lastMoveEventInfo = transformPoint(info, this.transformPagePoint);
4575
4577
  // Throttle mouse move event to once per frame
4576
4578
  sync.update(this.updatePoint, true);
4577
4579
  };
4578
4580
  this.handlePointerUp = (event, info) => {
4581
+ if (!isPrimaryPointer(event))
4582
+ return;
4579
4583
  this.end();
4580
4584
  const { onEnd, onSessionEnd } = this.handlers;
4581
4585
  const panInfo = getPanInfo(transformPoint(info, this.transformPagePoint), this.history);
@@ -5868,7 +5872,7 @@ function updateMotionValuesFromProps(element, next, prev) {
5868
5872
  * and warn against mismatches.
5869
5873
  */
5870
5874
  if (process.env.NODE_ENV === "development") {
5871
- warnOnce(nextValue.version === "8.0.0", `Attempting to mix Framer Motion versions ${nextValue.version} with 8.0.0 may not work as expected.`);
5875
+ warnOnce(nextValue.version === "8.0.2", `Attempting to mix Framer Motion versions ${nextValue.version} with 8.0.2 may not work as expected.`);
5872
5876
  }
5873
5877
  }
5874
5878
  else if (isMotionValue(prevValue)) {
@@ -9208,6 +9212,9 @@ function useVelocity(value) {
9208
9212
  return velocity;
9209
9213
  }
9210
9214
 
9215
+ function refWarning(name, ref) {
9216
+ heyListen.warning(Boolean(!ref || ref.current), `You have defined a ${name} options but the provided ref is not yet hydrated, probably because it's defined higher up the tree. Try calling useScroll() in the same component as the ref, or setting its \`layoutEffect: false\` option.`);
9217
+ }
9211
9218
  const createScrollMotionValues = () => ({
9212
9219
  scrollX: motionValue(0),
9213
9220
  scrollY: motionValue(0),
@@ -9220,6 +9227,8 @@ function useScroll({ container, target, layoutEffect = true, ...options } = {})
9220
9227
  ? useIsomorphicLayoutEffect
9221
9228
  : React.useEffect;
9222
9229
  useLifecycleEffect(() => {
9230
+ refWarning("target", target);
9231
+ refWarning("container", container);
9223
9232
  return dom.scroll(({ x, y }) => {
9224
9233
  values.scrollX.set(x.current);
9225
9234
  values.scrollXProgress.set(x.progress);
@@ -5,7 +5,7 @@ import { getAnimatableNone } from '../../render/dom/value-types/animatable-none.
5
5
  * This filters out orchestration options and returns true
6
6
  * if any options are left.
7
7
  */
8
- function isTransitionDefined({ when, delay: _delay, delayChildren, staggerChildren, staggerDirection, repeat, repeatType, repeatDelay, from, ...transition }) {
8
+ function isTransitionDefined({ when, delay: _delay, delayChildren, staggerChildren, staggerDirection, repeat, repeatType, repeatDelay, from, elapsed, ...transition }) {
9
9
  return !!Object.keys(transition).length;
10
10
  }
11
11
  function isZero(value) {
@@ -10,7 +10,7 @@ import { isWaapiSupportedEasing } from './easing.mjs';
10
10
  */
11
11
  const sampleDelta = 10; //ms
12
12
  function createAcceleratedAnimation(value, valueName, { onUpdate, onComplete, ...options }) {
13
- let { keyframes, duration = 0.3, elapsed = 0, ease } = options;
13
+ let { keyframes, duration = 300, elapsed = 0, ease } = options;
14
14
  /**
15
15
  * If this animation needs pre-generated keyframes then generate.
16
16
  */
@@ -50,12 +50,16 @@ class PanSession {
50
50
  onMove && onMove(this.lastMoveEvent, info);
51
51
  };
52
52
  this.handlePointerMove = (event, info) => {
53
+ if (!isPrimaryPointer(event))
54
+ return;
53
55
  this.lastMoveEvent = event;
54
56
  this.lastMoveEventInfo = transformPoint(info, this.transformPagePoint);
55
57
  // Throttle mouse move event to once per frame
56
58
  sync.update(this.updatePoint, true);
57
59
  };
58
60
  this.handlePointerUp = (event, info) => {
61
+ if (!isPrimaryPointer(event))
62
+ return;
59
63
  this.end();
60
64
  const { onEnd, onSessionEnd } = this.handlers;
61
65
  const panInfo = getPanInfo(transformPoint(info, this.transformPagePoint), this.history);
@@ -22,7 +22,7 @@ function updateMotionValuesFromProps(element, next, prev) {
22
22
  * and warn against mismatches.
23
23
  */
24
24
  if (process.env.NODE_ENV === "development") {
25
- warnOnce(nextValue.version === "8.0.0", `Attempting to mix Framer Motion versions ${nextValue.version} with 8.0.0 may not work as expected.`);
25
+ warnOnce(nextValue.version === "8.0.2", `Attempting to mix Framer Motion versions ${nextValue.version} with 8.0.2 may not work as expected.`);
26
26
  }
27
27
  }
28
28
  else if (isMotionValue(prevValue)) {
@@ -25,7 +25,7 @@ class MotionValue {
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 = "8.0.0";
28
+ this.version = "8.0.2";
29
29
  /**
30
30
  * Duration, in milliseconds, since last updating frame.
31
31
  *
@@ -2,8 +2,12 @@ import { scroll } from '@motionone/dom';
2
2
  import { motionValue } from './index.mjs';
3
3
  import { useConstant } from '../utils/use-constant.mjs';
4
4
  import { useEffect } from 'react';
5
+ import { warning } from 'hey-listen';
5
6
  import { useIsomorphicLayoutEffect } from '../utils/use-isomorphic-effect.mjs';
6
7
 
8
+ function refWarning(name, ref) {
9
+ warning(Boolean(!ref || ref.current), `You have defined a ${name} options but the provided ref is not yet hydrated, probably because it's defined higher up the tree. Try calling useScroll() in the same component as the ref, or setting its \`layoutEffect: false\` option.`);
10
+ }
7
11
  const createScrollMotionValues = () => ({
8
12
  scrollX: motionValue(0),
9
13
  scrollY: motionValue(0),
@@ -16,6 +20,8 @@ function useScroll({ container, target, layoutEffect = true, ...options } = {})
16
20
  ? useIsomorphicLayoutEffect
17
21
  : useEffect;
18
22
  useLifecycleEffect(() => {
23
+ refWarning("target", target);
24
+ refWarning("container", container);
19
25
  return scroll(({ x, y }) => {
20
26
  values.scrollX.set(x.current);
21
27
  values.scrollXProgress.set(x.progress);
@@ -2063,7 +2063,7 @@
2063
2063
  * This will be replaced by the build step with the latest version number.
2064
2064
  * When MotionValues are provided to motion components, warn if versions are mixed.
2065
2065
  */
2066
- this.version = "8.0.0";
2066
+ this.version = "8.0.2";
2067
2067
  /**
2068
2068
  * Duration, in milliseconds, since last updating frame.
2069
2069
  *
@@ -3603,7 +3603,7 @@
3603
3603
  */
3604
3604
  const sampleDelta = 10; //ms
3605
3605
  function createAcceleratedAnimation(value, valueName, { onUpdate, onComplete, ...options }) {
3606
- let { keyframes, duration = 0.3, elapsed = 0, ease } = options;
3606
+ let { keyframes, duration = 300, elapsed = 0, ease } = options;
3607
3607
  /**
3608
3608
  * If this animation needs pre-generated keyframes then generate.
3609
3609
  */
@@ -3858,7 +3858,7 @@
3858
3858
  * This filters out orchestration options and returns true
3859
3859
  * if any options are left.
3860
3860
  */
3861
- function isTransitionDefined({ when, delay: _delay, delayChildren, staggerChildren, staggerDirection, repeat, repeatType, repeatDelay, from, ...transition }) {
3861
+ function isTransitionDefined({ when, delay: _delay, delayChildren, staggerChildren, staggerDirection, repeat, repeatType, repeatDelay, from, elapsed, ...transition }) {
3862
3862
  return !!Object.keys(transition).length;
3863
3863
  }
3864
3864
  function isZero(value) {
@@ -4583,12 +4583,16 @@
4583
4583
  onMove && onMove(this.lastMoveEvent, info);
4584
4584
  };
4585
4585
  this.handlePointerMove = (event, info) => {
4586
+ if (!isPrimaryPointer(event))
4587
+ return;
4586
4588
  this.lastMoveEvent = event;
4587
4589
  this.lastMoveEventInfo = transformPoint(info, this.transformPagePoint);
4588
4590
  // Throttle mouse move event to once per frame
4589
4591
  sync.update(this.updatePoint, true);
4590
4592
  };
4591
4593
  this.handlePointerUp = (event, info) => {
4594
+ if (!isPrimaryPointer(event))
4595
+ return;
4592
4596
  this.end();
4593
4597
  const { onEnd, onSessionEnd } = this.handlers;
4594
4598
  const panInfo = getPanInfo(transformPoint(info, this.transformPagePoint), this.history);
@@ -5881,7 +5885,7 @@
5881
5885
  * and warn against mismatches.
5882
5886
  */
5883
5887
  {
5884
- warnOnce(nextValue.version === "8.0.0", `Attempting to mix Framer Motion versions ${nextValue.version} with 8.0.0 may not work as expected.`);
5888
+ warnOnce(nextValue.version === "8.0.2", `Attempting to mix Framer Motion versions ${nextValue.version} with 8.0.2 may not work as expected.`);
5885
5889
  }
5886
5890
  }
5887
5891
  else if (isMotionValue(prevValue)) {
@@ -9829,6 +9833,9 @@
9829
9833
  };
9830
9834
  }
9831
9835
 
9836
+ function refWarning(name, ref) {
9837
+ warning(Boolean(!ref || ref.current), `You have defined a ${name} options but the provided ref is not yet hydrated, probably because it's defined higher up the tree. Try calling useScroll() in the same component as the ref, or setting its \`layoutEffect: false\` option.`);
9838
+ }
9832
9839
  const createScrollMotionValues = () => ({
9833
9840
  scrollX: motionValue(0),
9834
9841
  scrollY: motionValue(0),
@@ -9841,6 +9848,8 @@
9841
9848
  ? useIsomorphicLayoutEffect
9842
9849
  : React.useEffect;
9843
9850
  useLifecycleEffect(() => {
9851
+ refWarning("target", target);
9852
+ refWarning("container", container);
9844
9853
  return scroll(({ x, y }) => {
9845
9854
  values.scrollX.set(x.current);
9846
9855
  values.scrollXProgress.set(x.progress);