framer-motion 8.4.4 → 8.4.6
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 +98 -45
- package/dist/es/animation/create-instant-animation.mjs +1 -2
- package/dist/es/animation/index.mjs +2 -4
- package/dist/es/animation/legacy-popmotion/index.mjs +19 -0
- package/dist/es/animation/optimized-appear/handoff.mjs +19 -2
- package/dist/es/animation/waapi/create-accelerated-animation.mjs +23 -15
- package/dist/es/gestures/use-hover-gesture.mjs +4 -4
- package/dist/es/gestures/use-tap-gesture.mjs +8 -4
- package/dist/es/motion/utils/use-visual-element.mjs +13 -5
- package/dist/es/render/utils/animation.mjs +1 -1
- package/dist/es/render/utils/motion-values.mjs +2 -2
- package/dist/es/value/index.mjs +7 -7
- package/dist/framer-motion.dev.js +98 -45
- package/dist/framer-motion.js +1 -1
- package/dist/index.d.ts +133 -133
- package/dist/projection.dev.js +54 -30
- package/dist/size-rollup-dom-animation-m.js +1 -1
- package/dist/size-rollup-dom-animation.js +1 -1
- package/dist/size-rollup-dom-max.js +1 -1
- package/dist/size-rollup-m.js +1 -1
- package/dist/size-rollup-motion.js +1 -1
- package/dist/size-webpack-dom-animation.js +1 -1
- package/dist/size-webpack-dom-max.js +1 -1
- package/dist/size-webpack-m.js +1 -1
- package/dist/three-entry.d.ts +62 -62
- package/package.json +9 -9
package/dist/index.d.ts
CHANGED
|
@@ -1561,6 +1561,139 @@ declare abstract class VisualElement<Instance = unknown, RenderState = unknown,
|
|
|
1561
1561
|
notify<EventName extends keyof VisualElementEventCallbacks>(eventName: EventName, ...args: any): void;
|
|
1562
1562
|
}
|
|
1563
1563
|
|
|
1564
|
+
interface Animation$1<V> {
|
|
1565
|
+
next: (t: number) => {
|
|
1566
|
+
value: V;
|
|
1567
|
+
done: boolean;
|
|
1568
|
+
};
|
|
1569
|
+
flipTarget: () => void;
|
|
1570
|
+
}
|
|
1571
|
+
/**
|
|
1572
|
+
* An update function. It accepts a timestamp used to advance the animation.
|
|
1573
|
+
*/
|
|
1574
|
+
declare type Update = (timestamp: number) => void;
|
|
1575
|
+
/**
|
|
1576
|
+
* Drivers accept a update function and call it at an interval. This interval
|
|
1577
|
+
* could be a synchronous loop, a setInterval, or tied to the device's framerate.
|
|
1578
|
+
*/
|
|
1579
|
+
interface DriverControls {
|
|
1580
|
+
start: () => void;
|
|
1581
|
+
stop: () => void;
|
|
1582
|
+
}
|
|
1583
|
+
declare type Driver = (update: Update) => DriverControls;
|
|
1584
|
+
|
|
1585
|
+
interface VelocityOptions {
|
|
1586
|
+
velocity?: number;
|
|
1587
|
+
restSpeed?: number;
|
|
1588
|
+
restDelta?: number;
|
|
1589
|
+
}
|
|
1590
|
+
interface AnimationLifecycleOptions<V> {
|
|
1591
|
+
onUpdate?: (v: V) => void;
|
|
1592
|
+
onComplete?: VoidFunction;
|
|
1593
|
+
onPlay?: VoidFunction;
|
|
1594
|
+
onRepeat?: VoidFunction;
|
|
1595
|
+
onStop?: VoidFunction;
|
|
1596
|
+
}
|
|
1597
|
+
interface AnimationPlaybackOptions {
|
|
1598
|
+
repeat?: number;
|
|
1599
|
+
repeatType?: "loop" | "reverse" | "mirror";
|
|
1600
|
+
repeatDelay?: number;
|
|
1601
|
+
}
|
|
1602
|
+
interface DurationSpringOptions {
|
|
1603
|
+
duration?: number;
|
|
1604
|
+
bounce?: number;
|
|
1605
|
+
}
|
|
1606
|
+
interface SpringOptions extends DurationSpringOptions, VelocityOptions {
|
|
1607
|
+
stiffness?: number;
|
|
1608
|
+
damping?: number;
|
|
1609
|
+
mass?: number;
|
|
1610
|
+
}
|
|
1611
|
+
interface DecayOptions extends VelocityOptions {
|
|
1612
|
+
keyframes?: number[];
|
|
1613
|
+
power?: number;
|
|
1614
|
+
timeConstant?: number;
|
|
1615
|
+
modifyTarget?: (v: number) => number;
|
|
1616
|
+
}
|
|
1617
|
+
interface InertiaOptions$1 extends DecayOptions {
|
|
1618
|
+
bounceStiffness?: number;
|
|
1619
|
+
bounceDamping?: number;
|
|
1620
|
+
min?: number;
|
|
1621
|
+
max?: number;
|
|
1622
|
+
}
|
|
1623
|
+
interface KeyframeOptions {
|
|
1624
|
+
ease?: Easing | Easing[];
|
|
1625
|
+
times?: number[];
|
|
1626
|
+
}
|
|
1627
|
+
interface AnimationOptions<V = any> extends AnimationLifecycleOptions<V>, AnimationPlaybackOptions, Omit<SpringOptions, "keyframes">, Omit<InertiaOptions$1, "keyframes">, KeyframeOptions {
|
|
1628
|
+
keyframes: V[];
|
|
1629
|
+
elapsed?: number;
|
|
1630
|
+
driver?: Driver;
|
|
1631
|
+
type?: "decay" | "spring" | "keyframes" | "tween";
|
|
1632
|
+
duration?: number;
|
|
1633
|
+
autoplay?: boolean;
|
|
1634
|
+
}
|
|
1635
|
+
/**
|
|
1636
|
+
* @public
|
|
1637
|
+
*/
|
|
1638
|
+
declare type ControlsAnimationDefinition = string | string[] | TargetAndTransition | TargetResolver;
|
|
1639
|
+
/**
|
|
1640
|
+
* @public
|
|
1641
|
+
*/
|
|
1642
|
+
interface AnimationControls {
|
|
1643
|
+
/**
|
|
1644
|
+
* Starts an animation on all linked components.
|
|
1645
|
+
*
|
|
1646
|
+
* @remarks
|
|
1647
|
+
*
|
|
1648
|
+
* ```jsx
|
|
1649
|
+
* controls.start("variantLabel")
|
|
1650
|
+
* controls.start({
|
|
1651
|
+
* x: 0,
|
|
1652
|
+
* transition: { duration: 1 }
|
|
1653
|
+
* })
|
|
1654
|
+
* ```
|
|
1655
|
+
*
|
|
1656
|
+
* @param definition - Properties or variant label to animate to
|
|
1657
|
+
* @param transition - Optional `transtion` to apply to a variant
|
|
1658
|
+
* @returns - A `Promise` that resolves when all animations have completed.
|
|
1659
|
+
*
|
|
1660
|
+
* @public
|
|
1661
|
+
*/
|
|
1662
|
+
start(definition: ControlsAnimationDefinition, transitionOverride?: Transition): Promise<any>;
|
|
1663
|
+
/**
|
|
1664
|
+
* Instantly set to a set of properties or a variant.
|
|
1665
|
+
*
|
|
1666
|
+
* ```jsx
|
|
1667
|
+
* // With properties
|
|
1668
|
+
* controls.set({ opacity: 0 })
|
|
1669
|
+
*
|
|
1670
|
+
* // With variants
|
|
1671
|
+
* controls.set("hidden")
|
|
1672
|
+
* ```
|
|
1673
|
+
*
|
|
1674
|
+
* @privateRemarks
|
|
1675
|
+
* We could perform a similar trick to `.start` where this can be called before mount
|
|
1676
|
+
* and we maintain a list of of pending actions that get applied on mount. But the
|
|
1677
|
+
* expectation of `set` is that it happens synchronously and this would be difficult
|
|
1678
|
+
* to do before any children have even attached themselves. It's also poor practise
|
|
1679
|
+
* and we should discourage render-synchronous `.start` calls rather than lean into this.
|
|
1680
|
+
*
|
|
1681
|
+
* @public
|
|
1682
|
+
*/
|
|
1683
|
+
set(definition: ControlsAnimationDefinition): void;
|
|
1684
|
+
/**
|
|
1685
|
+
* Stops animations on all linked components.
|
|
1686
|
+
*
|
|
1687
|
+
* ```jsx
|
|
1688
|
+
* controls.stop()
|
|
1689
|
+
* ```
|
|
1690
|
+
*
|
|
1691
|
+
* @public
|
|
1692
|
+
*/
|
|
1693
|
+
stop(): void;
|
|
1694
|
+
mount(): () => void;
|
|
1695
|
+
}
|
|
1696
|
+
|
|
1564
1697
|
/**
|
|
1565
1698
|
* @public
|
|
1566
1699
|
*/
|
|
@@ -1714,139 +1847,6 @@ declare class MotionValue<V = any> {
|
|
|
1714
1847
|
}
|
|
1715
1848
|
declare function motionValue<V>(init: V, options?: MotionValueOptions): MotionValue<V>;
|
|
1716
1849
|
|
|
1717
|
-
interface Animation$1<V> {
|
|
1718
|
-
next: (t: number) => {
|
|
1719
|
-
value: V;
|
|
1720
|
-
done: boolean;
|
|
1721
|
-
};
|
|
1722
|
-
flipTarget: () => void;
|
|
1723
|
-
}
|
|
1724
|
-
/**
|
|
1725
|
-
* An update function. It accepts a timestamp used to advance the animation.
|
|
1726
|
-
*/
|
|
1727
|
-
declare type Update = (timestamp: number) => void;
|
|
1728
|
-
/**
|
|
1729
|
-
* Drivers accept a update function and call it at an interval. This interval
|
|
1730
|
-
* could be a synchronous loop, a setInterval, or tied to the device's framerate.
|
|
1731
|
-
*/
|
|
1732
|
-
interface DriverControls {
|
|
1733
|
-
start: () => void;
|
|
1734
|
-
stop: () => void;
|
|
1735
|
-
}
|
|
1736
|
-
declare type Driver = (update: Update) => DriverControls;
|
|
1737
|
-
|
|
1738
|
-
interface VelocityOptions {
|
|
1739
|
-
velocity?: number;
|
|
1740
|
-
restSpeed?: number;
|
|
1741
|
-
restDelta?: number;
|
|
1742
|
-
}
|
|
1743
|
-
interface AnimationLifecycleOptions<V> {
|
|
1744
|
-
onUpdate?: (v: V) => void;
|
|
1745
|
-
onComplete?: VoidFunction;
|
|
1746
|
-
onPlay?: VoidFunction;
|
|
1747
|
-
onRepeat?: VoidFunction;
|
|
1748
|
-
onStop?: VoidFunction;
|
|
1749
|
-
}
|
|
1750
|
-
interface AnimationPlaybackOptions {
|
|
1751
|
-
repeat?: number;
|
|
1752
|
-
repeatType?: "loop" | "reverse" | "mirror";
|
|
1753
|
-
repeatDelay?: number;
|
|
1754
|
-
}
|
|
1755
|
-
interface DurationSpringOptions {
|
|
1756
|
-
duration?: number;
|
|
1757
|
-
bounce?: number;
|
|
1758
|
-
}
|
|
1759
|
-
interface SpringOptions extends DurationSpringOptions, VelocityOptions {
|
|
1760
|
-
stiffness?: number;
|
|
1761
|
-
damping?: number;
|
|
1762
|
-
mass?: number;
|
|
1763
|
-
}
|
|
1764
|
-
interface DecayOptions extends VelocityOptions {
|
|
1765
|
-
keyframes?: number[];
|
|
1766
|
-
power?: number;
|
|
1767
|
-
timeConstant?: number;
|
|
1768
|
-
modifyTarget?: (v: number) => number;
|
|
1769
|
-
}
|
|
1770
|
-
interface InertiaOptions$1 extends DecayOptions {
|
|
1771
|
-
bounceStiffness?: number;
|
|
1772
|
-
bounceDamping?: number;
|
|
1773
|
-
min?: number;
|
|
1774
|
-
max?: number;
|
|
1775
|
-
}
|
|
1776
|
-
interface KeyframeOptions {
|
|
1777
|
-
ease?: Easing | Easing[];
|
|
1778
|
-
times?: number[];
|
|
1779
|
-
}
|
|
1780
|
-
interface AnimationOptions<V = any> extends AnimationLifecycleOptions<V>, AnimationPlaybackOptions, Omit<SpringOptions, "keyframes">, Omit<InertiaOptions$1, "keyframes">, KeyframeOptions {
|
|
1781
|
-
keyframes: V[];
|
|
1782
|
-
elapsed?: number;
|
|
1783
|
-
driver?: Driver;
|
|
1784
|
-
type?: "decay" | "spring" | "keyframes" | "tween";
|
|
1785
|
-
duration?: number;
|
|
1786
|
-
autoplay?: boolean;
|
|
1787
|
-
}
|
|
1788
|
-
/**
|
|
1789
|
-
* @public
|
|
1790
|
-
*/
|
|
1791
|
-
declare type ControlsAnimationDefinition = string | string[] | TargetAndTransition | TargetResolver;
|
|
1792
|
-
/**
|
|
1793
|
-
* @public
|
|
1794
|
-
*/
|
|
1795
|
-
interface AnimationControls {
|
|
1796
|
-
/**
|
|
1797
|
-
* Starts an animation on all linked components.
|
|
1798
|
-
*
|
|
1799
|
-
* @remarks
|
|
1800
|
-
*
|
|
1801
|
-
* ```jsx
|
|
1802
|
-
* controls.start("variantLabel")
|
|
1803
|
-
* controls.start({
|
|
1804
|
-
* x: 0,
|
|
1805
|
-
* transition: { duration: 1 }
|
|
1806
|
-
* })
|
|
1807
|
-
* ```
|
|
1808
|
-
*
|
|
1809
|
-
* @param definition - Properties or variant label to animate to
|
|
1810
|
-
* @param transition - Optional `transtion` to apply to a variant
|
|
1811
|
-
* @returns - A `Promise` that resolves when all animations have completed.
|
|
1812
|
-
*
|
|
1813
|
-
* @public
|
|
1814
|
-
*/
|
|
1815
|
-
start(definition: ControlsAnimationDefinition, transitionOverride?: Transition): Promise<any>;
|
|
1816
|
-
/**
|
|
1817
|
-
* Instantly set to a set of properties or a variant.
|
|
1818
|
-
*
|
|
1819
|
-
* ```jsx
|
|
1820
|
-
* // With properties
|
|
1821
|
-
* controls.set({ opacity: 0 })
|
|
1822
|
-
*
|
|
1823
|
-
* // With variants
|
|
1824
|
-
* controls.set("hidden")
|
|
1825
|
-
* ```
|
|
1826
|
-
*
|
|
1827
|
-
* @privateRemarks
|
|
1828
|
-
* We could perform a similar trick to `.start` where this can be called before mount
|
|
1829
|
-
* and we maintain a list of of pending actions that get applied on mount. But the
|
|
1830
|
-
* expectation of `set` is that it happens synchronously and this would be difficult
|
|
1831
|
-
* to do before any children have even attached themselves. It's also poor practise
|
|
1832
|
-
* and we should discourage render-synchronous `.start` calls rather than lean into this.
|
|
1833
|
-
*
|
|
1834
|
-
* @public
|
|
1835
|
-
*/
|
|
1836
|
-
set(definition: ControlsAnimationDefinition): void;
|
|
1837
|
-
/**
|
|
1838
|
-
* Stops animations on all linked components.
|
|
1839
|
-
*
|
|
1840
|
-
* ```jsx
|
|
1841
|
-
* controls.stop()
|
|
1842
|
-
* ```
|
|
1843
|
-
*
|
|
1844
|
-
* @public
|
|
1845
|
-
*/
|
|
1846
|
-
stop(): void;
|
|
1847
|
-
mount(): () => void;
|
|
1848
|
-
}
|
|
1849
|
-
|
|
1850
1850
|
/**
|
|
1851
1851
|
* Passed in to pan event handlers like `onPan` the `PanInfo` object contains
|
|
1852
1852
|
* information about the current state of the tap gesture such as its
|
package/dist/projection.dev.js
CHANGED
|
@@ -1183,6 +1183,25 @@
|
|
|
1183
1183
|
onStop && onStop();
|
|
1184
1184
|
driverControls && driverControls.stop();
|
|
1185
1185
|
},
|
|
1186
|
+
/**
|
|
1187
|
+
* Set the current time of the animation. This is purposefully
|
|
1188
|
+
* mirroring the WAAPI animation API to make them interchanagable.
|
|
1189
|
+
* Going forward this file should be ported more towards
|
|
1190
|
+
* https://github.com/motiondivision/motionone/blob/main/packages/animation/src/Animation.ts
|
|
1191
|
+
* Which behaviourally adheres to WAAPI as far as possible.
|
|
1192
|
+
*
|
|
1193
|
+
* WARNING: This is not safe to use for most animations. We currently
|
|
1194
|
+
* only use it for handoff from WAAPI within Framer.
|
|
1195
|
+
*
|
|
1196
|
+
* This animation function consumes time every frame rather than being sampled for time.
|
|
1197
|
+
* So the sample() method performs some headless frames to ensure
|
|
1198
|
+
* repeats are handled correctly. Ideally in the future we will replace
|
|
1199
|
+
* that method with this, once repeat calculations are pure.
|
|
1200
|
+
*/
|
|
1201
|
+
set currentTime(t) {
|
|
1202
|
+
elapsed = initialElapsed;
|
|
1203
|
+
update(t);
|
|
1204
|
+
},
|
|
1186
1205
|
/**
|
|
1187
1206
|
* animate() can't yet be sampled for time, instead it
|
|
1188
1207
|
* consumes time. So to sample it we have to run a low
|
|
@@ -1339,21 +1358,29 @@
|
|
|
1339
1358
|
/**
|
|
1340
1359
|
* Animation interrupt callback.
|
|
1341
1360
|
*/
|
|
1342
|
-
return
|
|
1343
|
-
|
|
1344
|
-
|
|
1345
|
-
|
|
1346
|
-
|
|
1347
|
-
|
|
1348
|
-
|
|
1349
|
-
|
|
1350
|
-
|
|
1351
|
-
|
|
1352
|
-
|
|
1353
|
-
|
|
1354
|
-
|
|
1355
|
-
|
|
1356
|
-
|
|
1361
|
+
return {
|
|
1362
|
+
get currentTime() {
|
|
1363
|
+
return animation.currentTime || 0;
|
|
1364
|
+
},
|
|
1365
|
+
set currentTime(t) {
|
|
1366
|
+
animation.currentTime = t;
|
|
1367
|
+
},
|
|
1368
|
+
stop: () => {
|
|
1369
|
+
/**
|
|
1370
|
+
* WAAPI doesn't natively have any interruption capabilities.
|
|
1371
|
+
*
|
|
1372
|
+
* Rather than read commited styles back out of the DOM, we can
|
|
1373
|
+
* create a renderless JS animation and sample it twice to calculate
|
|
1374
|
+
* its current value, "previous" value, and therefore allow
|
|
1375
|
+
* Motion to calculate velocity for any subsequent animation.
|
|
1376
|
+
*/
|
|
1377
|
+
const { currentTime } = animation;
|
|
1378
|
+
if (currentTime) {
|
|
1379
|
+
const sampleAnimation = animate$1({ ...options, autoplay: false });
|
|
1380
|
+
value.setWithVelocity(sampleAnimation.sample(currentTime - sampleDelta).value, sampleAnimation.sample(currentTime).value, sampleDelta);
|
|
1381
|
+
}
|
|
1382
|
+
sync.update(() => animation.cancel());
|
|
1383
|
+
},
|
|
1357
1384
|
};
|
|
1358
1385
|
}
|
|
1359
1386
|
|
|
@@ -1377,9 +1404,8 @@
|
|
|
1377
1404
|
const setValue = () => {
|
|
1378
1405
|
onUpdate && onUpdate(keyframes[keyframes.length - 1]);
|
|
1379
1406
|
onComplete && onComplete();
|
|
1380
|
-
return () => { };
|
|
1381
1407
|
};
|
|
1382
|
-
return elapsed ? delay(setValue, -elapsed) : setValue();
|
|
1408
|
+
return elapsed ? { stop: delay(setValue, -elapsed) } : setValue();
|
|
1383
1409
|
}
|
|
1384
1410
|
|
|
1385
1411
|
function inertia({ keyframes, velocity = 0, min, max, power = 0.8, timeConstant = 750, bounceStiffness = 500, bounceDamping = 10, restDelta = 1, modifyTarget, driver, onUpdate, onComplete, onStop, }) {
|
|
@@ -1788,8 +1814,7 @@
|
|
|
1788
1814
|
* If this is an inertia animation, we currently don't support pre-generating
|
|
1789
1815
|
* keyframes for this as such it must always run on the main thread.
|
|
1790
1816
|
*/
|
|
1791
|
-
|
|
1792
|
-
return () => animation.stop();
|
|
1817
|
+
return inertia(options);
|
|
1793
1818
|
}
|
|
1794
1819
|
/**
|
|
1795
1820
|
* If there's no transition defined for this value, we can generate
|
|
@@ -1827,8 +1852,7 @@
|
|
|
1827
1852
|
/**
|
|
1828
1853
|
* If we didn't create an accelerated animation, create a JS animation
|
|
1829
1854
|
*/
|
|
1830
|
-
|
|
1831
|
-
return () => animation.stop();
|
|
1855
|
+
return animate$1(options);
|
|
1832
1856
|
};
|
|
1833
1857
|
};
|
|
1834
1858
|
|
|
@@ -1901,7 +1925,7 @@
|
|
|
1901
1925
|
* This will be replaced by the build step with the latest version number.
|
|
1902
1926
|
* When MotionValues are provided to motion components, warn if versions are mixed.
|
|
1903
1927
|
*/
|
|
1904
|
-
this.version = "8.4.
|
|
1928
|
+
this.version = "8.4.6";
|
|
1905
1929
|
/**
|
|
1906
1930
|
* Duration, in milliseconds, since last updating frame.
|
|
1907
1931
|
*
|
|
@@ -2140,11 +2164,11 @@
|
|
|
2140
2164
|
*
|
|
2141
2165
|
* @internal
|
|
2142
2166
|
*/
|
|
2143
|
-
start(
|
|
2167
|
+
start(startAnimation) {
|
|
2144
2168
|
this.stop();
|
|
2145
2169
|
return new Promise((resolve) => {
|
|
2146
2170
|
this.hasAnimated = true;
|
|
2147
|
-
this.
|
|
2171
|
+
this.animation = startAnimation(resolve) || null;
|
|
2148
2172
|
if (this.events.animationStart) {
|
|
2149
2173
|
this.events.animationStart.notify();
|
|
2150
2174
|
}
|
|
@@ -2161,8 +2185,8 @@
|
|
|
2161
2185
|
* @public
|
|
2162
2186
|
*/
|
|
2163
2187
|
stop() {
|
|
2164
|
-
if (this.
|
|
2165
|
-
this.
|
|
2188
|
+
if (this.animation) {
|
|
2189
|
+
this.animation.stop();
|
|
2166
2190
|
if (this.events.animationCancel) {
|
|
2167
2191
|
this.events.animationCancel.notify();
|
|
2168
2192
|
}
|
|
@@ -2175,10 +2199,10 @@
|
|
|
2175
2199
|
* @public
|
|
2176
2200
|
*/
|
|
2177
2201
|
isAnimating() {
|
|
2178
|
-
return !!this.
|
|
2202
|
+
return !!this.animation;
|
|
2179
2203
|
}
|
|
2180
2204
|
clearAnimation() {
|
|
2181
|
-
this.
|
|
2205
|
+
this.animation = null;
|
|
2182
2206
|
}
|
|
2183
2207
|
/**
|
|
2184
2208
|
* Destroy and clean up subscribers to this `MotionValue`.
|
|
@@ -5062,7 +5086,7 @@
|
|
|
5062
5086
|
* and warn against mismatches.
|
|
5063
5087
|
*/
|
|
5064
5088
|
{
|
|
5065
|
-
warnOnce(nextValue.version === "8.4.
|
|
5089
|
+
warnOnce(nextValue.version === "8.4.6", `Attempting to mix Framer Motion versions ${nextValue.version} with 8.4.6 may not work as expected.`);
|
|
5066
5090
|
}
|
|
5067
5091
|
}
|
|
5068
5092
|
else if (isMotionValue(prevValue)) {
|
|
@@ -5088,7 +5112,7 @@
|
|
|
5088
5112
|
}
|
|
5089
5113
|
else {
|
|
5090
5114
|
const latestValue = element.getStaticValue(key);
|
|
5091
|
-
element.addValue(key, motionValue(latestValue !== undefined ? latestValue : nextValue));
|
|
5115
|
+
element.addValue(key, motionValue(latestValue !== undefined ? latestValue : nextValue, { owner: element }));
|
|
5092
5116
|
}
|
|
5093
5117
|
}
|
|
5094
5118
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import*as t from"react";import n,{createContext as e,useContext as r,useLayoutEffect as o,useEffect as a,useRef as s,useCallback as i,useMemo as u,forwardRef as c,createElement as l}from"react";import{i as d,P as m,M as f,a as p,b as g,c as y,f as v,u as h,g as S,S as
|
|
1
|
+
import*as t from"react";import n,{createContext as e,useContext as r,useLayoutEffect as o,useEffect as a,useRef as s,useCallback as i,useMemo as u,forwardRef as c,createElement as l}from"react";import{i as d,P as m,M as f,a as p,b as g,c as y,f as v,u as h,g as S,S as w,L as E,d as C,e as V,h as A,j as b,k as M,l as P,r as T,m as j,n as x,o as D,s as L,p as B,q as F}from"./size-rollup-dom-max-assets.js";const I=e({});const O=d?o:a,k=e({strict:!1});function H(t,n,e,o){const i=r(I).visualElement,u=r(k),c=r(m),l=r(f).reducedMotion,d=s();o=o||u.renderer,!d.current&&o&&(d.current=o(t,{visualState:n,parent:i,props:e,presenceId:c?c.id:void 0,blockInitialAnimation:!!c&&!1===c.initial,reducedMotionConfig:l}));const p=d.current;O(()=>{p&&p.render()});return(window.MotionAppearAnimations?O:a)(()=>{p&&p.animationState&&p.animationState.animateChanges()}),p}function N(t){const{initial:n,animate:e}=function(t,n){if(g(t)){const{initial:n,animate:e}=t;return{initial:!1===n||y(n)?n:void 0,animate:y(e)?e:void 0}}return!1!==t.inherit?n:{}}(t,r(I));return u(()=>({initial:n,animate:e}),[R(n),R(e)])}function R(t){return Array.isArray(t)?t.join(" "):t}let U=1;class K extends n.Component{getSnapshotBeforeUpdate(){const{visualElement:t,props:n}=this.props;return t&&t.setProps(n),null}componentDidUpdate(){}render(){return this.props.children}}const W=Symbol.for("motionComponentSymbol");function q({preloadedFeatures:n,createVisualElement:e,projectionNodeConstructor:o,useRender:a,useVisualState:s,Component:u}){n&&function(t){for(const n in t)"projectionNodeConstructor"===n?v.projectionNodeConstructor=t[n]:v[n].Component=t[n]}(n);const l=c((function(c,l){const m={...r(f),...c,layoutId:_(c)},{isStatic:g}=m;let y=null;const E=N(c),C=g?void 0:h(()=>{if(S.hasEverUpdated)return U++}),V=s(c,g);if(!g&&d){E.visualElement=H(u,V,m,e);const t=r(k).strict,a=r(w);E.visualElement&&(y=E.visualElement.loadFeatures(m,t,n,C,o||v.projectionNodeConstructor,a))}return t.createElement(K,{visualElement:E.visualElement,props:m},y,t.createElement(I.Provider,{value:E},a(u,c,C,function(t,n,e){return i(r=>{r&&t.mount&&t.mount(r),n&&(r?n.mount(r):n.unmount()),e&&("function"==typeof e?e(r):p(e)&&(e.current=r))},[n])}(V,E.visualElement,l),V,g,E.visualElement)))}));return l[W]=u,l}function _({layoutId:t}){const n=r(E).id;return n&&void 0!==t?n+"-"+t:t}const z=()=>({style:{},transform:{},transformKeys:[],transformOrigin:{},vars:{}});function X(t,n,e){for(const r in n)C(n[r])||V(r,e)||(t[r]=n[r])}function Y(t,n,e){const r={};return X(r,t.style||{},t),Object.assign(r,function({transformTemplate:t},n,e){return u(()=>{const r={style:{},transform:{},transformKeys:[],transformOrigin:{},vars:{}};return A(r,n,{enableHardwareAcceleration:!e},t),Object.assign({},r.vars,r.style)},[n])}(t,n,e)),t.transformValues?t.transformValues(r):r}function G(t,n,e){const r={},o=Y(t,n,e);return t.drag&&!1!==t.dragListener&&(r.draggable=!1,o.userSelect=o.WebkitUserSelect=o.WebkitTouchCallout="none",o.touchAction=!0===t.drag?"none":"pan-"+("x"===t.drag?"y":"x")),r.style=o,r}const J=new Set(["initial","style","values","variants","transition","transformTemplate","transformValues","custom","inherit","layout","layoutId","layoutDependency","onLayoutAnimationStart","onLayoutAnimationComplete","onLayoutMeasure","onBeforeLayoutMeasure","onAnimationStart","onAnimationComplete","onUpdate","onDragStart","onDrag","onDragEnd","onMeasureDragConstraints","onDirectionLock","onDragTransitionEnd","drag","dragControls","dragListener","dragConstraints","dragDirectionLock","dragSnapToOrigin","_dragX","_dragY","dragElastic","dragMomentum","dragPropagation","dragTransition","onHoverStart","onHoverEnd","layoutScroll","whileInView","onViewportEnter","onViewportLeave","viewport","whileTap","onTap","onTapStart","onTapCancel","animate","exit","variants","whileHover","whileTap","whileFocus","whileDrag","whileInView","onPan","onPanStart","onPanSessionStart","onPanEnd"]);function Q(t){return J.has(t)}let Z=t=>!Q(t);try{($=require("@emotion/is-prop-valid").default)&&(Z=t=>t.startsWith("on")?!Q(t):$(t))}catch(t){}var $;const tt=()=>({style:{},transform:{},transformKeys:[],transformOrigin:{},vars:{},attrs:{}});function nt(t,n,e,r){const o=u(()=>{const e={style:{},transform:{},transformKeys:[],transformOrigin:{},vars:{},attrs:{}};return b(e,n,{enableHardwareAcceleration:!1},M(r),t.transformTemplate),{...e.attrs,style:{...e.style}}},[n]);if(t.style){const n={};X(n,t.style,t),o.style={...n,...o.style}}return o}function et(t=!1){return(n,e,r,o,{latestValues:a},s)=>{const i=(P(n)?nt:G)(e,a,s,n),c={...function(t,n,e){const r={};for(const o in t)"values"===o&&"object"==typeof t.values||(Z(o)||!0===e&&Q(o)||!n&&!Q(o)||t.draggable&&o.startsWith("onDrag"))&&(r[o]=t[o]);return r}(e,"string"==typeof n,t),...i,ref:o},{children:d}=e,m=u(()=>C(d)?d.get():d,[d]);return r&&(c["data-projection-id"]=r),l(n,{...c,children:m})}}const rt=t=>(n,e)=>{const o=r(I),a=r(m),s=()=>function({scrapeMotionValuesFromProps:t,createRenderState:n,onMount:e},r,o,a){const s={latestValues:ot(r,o,a,t),renderState:n()};return e&&(s.mount=t=>e(r,t,s)),s}(t,n,o,a);return e?s():h(s)};function ot(t,n,e,r){const o={},a=r(t,{});for(const t in a)o[t]=T(a[t]);let{initial:s,animate:i}=t;const u=g(t),c=j(t);n&&c&&!u&&!1!==t.inherit&&(void 0===s&&(s=n.initial),void 0===i&&(i=n.animate));let l=!!e&&!1===e.initial;l=l||!1===s;const d=l?i:s;if(d&&"boolean"!=typeof d&&!x(d)){(Array.isArray(d)?d:[d]).forEach(n=>{const e=D(t,n);if(!e)return;const{transitionEnd:r,transition:a,...s}=e;for(const t in s){let n=s[t];if(Array.isArray(n)){n=n[l?n.length-1:0]}null!==n&&(o[t]=n)}for(const t in r)o[t]=r[t]})}return o}const at={useVisualState:rt({scrapeMotionValuesFromProps:L,createRenderState:tt,onMount:(t,n,{renderState:e,latestValues:r})=>{try{e.dimensions="function"==typeof n.getBBox?n.getBBox():n.getBoundingClientRect()}catch(t){e.dimensions={x:0,y:0,width:0,height:0}}b(e,r,{enableHardwareAcceleration:!1},M(n.tagName),t.transformTemplate),B(n,e)}})},st={useVisualState:rt({scrapeMotionValuesFromProps:F,createRenderState:z})};const it=function(t){function n(n,e={}){return q(t(n,e))}if("undefined"==typeof Proxy)return n;const e=new Map;return new Proxy(n,{get:(t,r)=>(e.has(r)||e.set(r,n(r)),e.get(r))})}((function(t,{forwardMotionProps:n=!1},e,r,o){return{...P(t)?at:st,preloadedFeatures:e,useRender:et(n),createVisualElement:r,projectionNodeConstructor:o,Component:t}}));export{it as m};
|