framer-motion 12.8.0 → 12.9.0
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/client.js +1 -1
- package/dist/cjs/{create-Bv1Fn_mR.js → create-BMX8oz9O.js} +66 -142
- package/dist/cjs/dom.js +29 -57
- package/dist/cjs/index.js +1 -1
- package/dist/cjs/m.js +17 -136
- package/dist/dom-mini.js +1 -1
- package/dist/dom.js +1 -1
- package/dist/es/animation/interfaces/visual-element-target.mjs +11 -0
- package/dist/es/motion/utils/use-visual-state.mjs +1 -10
- package/dist/es/render/VisualElement.mjs +1 -3
- package/dist/es/render/svg/SVGVisualElement.mjs +1 -12
- package/dist/es/render/svg/config-motion.mjs +0 -44
- package/dist/es/render/svg/utils/build-attrs.mjs +16 -11
- package/dist/es/render/utils/motion-values.mjs +1 -1
- package/dist/framer-motion.dev.js +128 -173
- package/dist/framer-motion.js +1 -1
- package/dist/mini.js +1 -1
- package/dist/size-rollup-animate.js +1 -1
- package/dist/size-rollup-dom-animation-assets.js +1 -1
- 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-assets.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-rollup-waapi-animate.js +1 -1
- package/dist/types/client.d.ts +1 -1
- package/dist/types/index.d.ts +2 -2
- package/dist/{types.d-DUA-weyD.d.ts → types.d-DDSxwf0n.d.ts} +2 -12
- package/package.json +4 -4
- package/dist/es/render/svg/utils/measure.mjs +0 -19
- package/dist/es/render/svg/utils/transform-origin.mjs +0 -18
|
@@ -1 +1 @@
|
|
|
1
|
-
function t(t){let e;return()=>(void 0===e&&(e=t()),e)}const e=t=>t,i=t=>1e3*t,n=t=>t/1e3,s=t=>null!==t;class a{constructor(){this.count=0,this.updateFinished()}get finished(){return this._finished}updateFinished(){this.count++,this._finished=new Promise((t=>{this.resolve=t}))}notifyFinished(){this.resolve()}then(t,e){return this.finished.then(t,e)}}function o(t){for(let e=1;e<t.length;e++)t[e]??(t[e]=t[e-1])}const r=t=>t.startsWith("--");const l=t((()=>void 0!==window.ScrollTimeline)),
|
|
1
|
+
function t(t){let e;return()=>(void 0===e&&(e=t()),e)}const e=t=>t,i=t=>1e3*t,n=t=>t/1e3,s=t=>null!==t;class a{constructor(){this.count=0,this.updateFinished()}get finished(){return this._finished}updateFinished(){this.count++,this._finished=new Promise((t=>{this.resolve=t}))}notifyFinished(){this.resolve()}then(t,e){return this.finished.then(t,e)}}function o(t){for(let e=1;e<t.length;e++)t[e]??(t[e]=t[e-1])}const r=t=>t.startsWith("--");const l=t((()=>void 0!==window.ScrollTimeline)),h={};function u(e,i){const n=t(e);return()=>h[i]??n()}const m=u((()=>{try{document.createElement("div").animate({opacity:0},{easing:"linear(0, 1)"})}catch(t){return!1}return!0}),"linearEasing"),d=([t,e,i,n])=>`cubic-bezier(${t}, ${e}, ${i}, ${n})`,c={linear:"linear",ease:"ease",easeIn:"ease-in",easeOut:"ease-out",easeInOut:"ease-in-out",circIn:d([0,.65,.55,1]),circOut:d([.55,0,1,.45]),backIn:d([.31,.01,.66,-.59]),backOut:d([.33,1.53,.69,.99])};function p(t,e){return t?"function"==typeof t?m()?((t,e,i=10)=>{let n="";const s=Math.max(Math.round(e/i),2);for(let e=0;e<s;e++)n+=t(e/(s-1))+", ";return`linear(${n.substring(0,n.length-2)})`})(t,e):"ease-out":(t=>Array.isArray(t)&&"number"==typeof t[0])(t)?d(t):Array.isArray(t)?t.map((t=>p(t,e)||c.easeOut)):c[t]:void 0}class f extends a{constructor(t){if(super(),this.finishedTime=null,this.isStopped=!1,!t)return;const{element:e,name:i,keyframes:n,pseudoElement:a,allowFlatten:o=!1,finalKeyframe:l,onComplete:h}=t;this.isPseudoElement=Boolean(a),this.allowFlatten=o,this.options=t,t.type;const u=function({type:t,...e}){return function(t){return"function"==typeof t&&"applyToOptions"in t}(t)&&m()?t.applyToOptions(e):(e.duration??(e.duration=300),e.ease??(e.ease="easeOut"),e)}(t);this.animation=function(t,e,i,{delay:n=0,duration:s=300,repeat:a=0,repeatType:o="loop",ease:r="easeOut",times:l}={},h){const u={[e]:i};l&&(u.offset=l);const m=p(r,s);Array.isArray(m)&&(u.easing=m);const d={delay:n,duration:s,easing:Array.isArray(m)?"linear":m,fill:"both",iterations:a+1,direction:"reverse"===o?"alternate":"normal"};return h&&(d.pseudoElement=h),t.animate(u,d)}(e,i,n,u,a),!1===u.autoplay&&this.animation.pause(),this.animation.onfinish=()=>{if(this.finishedTime=this.time,!a){const t=function(t,{repeat:e,repeatType:i="loop"},n,a=1){const o=t.filter(s),r=a<0||e&&"loop"!==i&&e%2==1?0:o.length-1;return r&&void 0!==n?n:o[r]}(n,this.options,l,this.speed);this.updateMotionValue?this.updateMotionValue(t):function(t,e,i){r(e)?t.style.setProperty(e,i):t.style[e]=i}(e,i,t),this.animation.cancel()}h?.(),this.notifyFinished()},this.animation.oncancel=()=>this.notifyFinished()}play(){this.isStopped||(this.animation.play(),"finished"===this.state&&this.updateFinished())}pause(){this.animation.pause()}complete(){this.animation.finish?.()}cancel(){try{this.animation.cancel()}catch(t){}}stop(){if(this.isStopped)return;this.isStopped=!0;const{state:t}=this;"idle"!==t&&"finished"!==t&&(this.updateMotionValue?this.updateMotionValue():this.commitStyles(),this.isPseudoElement||this.cancel())}commitStyles(){this.isPseudoElement||this.animation.commitStyles?.()}get duration(){const t=this.animation.effect?.getComputedTiming?.().duration||0;return n(Number(t))}get time(){return n(Number(this.animation.currentTime)||0)}set time(t){this.finishedTime=null,this.animation.currentTime=i(t)}get speed(){return this.animation.playbackRate}set speed(t){t<0&&(this.finishedTime=null),this.animation.playbackRate=t}get state(){return null!==this.finishedTime?"finished":this.animation.playState}get startTime(){return Number(this.animation.startTime)}set startTime(t){this.animation.startTime=t}attachTimeline({timeline:t,observe:i}){return this.allowFlatten&&this.animation.effect?.updateTiming({easing:"linear"}),this.animation.onfinish=null,t&&l()?(this.animation.timeline=t,e):i(this)}}class y{constructor(t){this.stop=()=>this.runAll("stop"),this.animations=t.filter(Boolean)}get finished(){return Promise.all(this.animations.map((t=>t.finished)))}getAll(t){return this.animations[0][t]}setAll(t,e){for(let i=0;i<this.animations.length;i++)this.animations[i][t]=e}attachTimeline(t){const e=this.animations.map((e=>e.attachTimeline(t)));return()=>{e.forEach(((t,e)=>{t&&t(),this.animations[e].stop()}))}}get time(){return this.getAll("time")}set time(t){this.setAll("time",t)}get speed(){return this.getAll("speed")}set speed(t){this.setAll("speed",t)}get state(){return this.getAll("state")}get startTime(){return this.getAll("startTime")}get duration(){let t=0;for(let e=0;e<this.animations.length;e++)t=Math.max(t,this.animations[e].duration);return t}runAll(t){this.animations.forEach((e=>e[t]()))}play(){this.runAll("play")}pause(){this.runAll("pause")}cancel(){this.runAll("cancel")}complete(){this.runAll("complete")}}class g extends y{then(t,e){return this.finished.finally(t).then((()=>{}))}}const T=new WeakMap,b=(t,e="")=>`${t}:${e}`;function A(t){const e=T.get(t)||new Map;return T.set(t,e),e}function w(t,e){return t?.[e]??t?.default??t}const v=new Set(["borderWidth","borderTopWidth","borderRightWidth","borderBottomWidth","borderLeftWidth","borderRadius","radius","borderTopLeftRadius","borderTopRightRadius","borderBottomRightRadius","borderBottomLeftRadius","width","maxWidth","height","maxHeight","top","right","bottom","left","padding","paddingTop","paddingRight","paddingBottom","paddingLeft","margin","marginTop","marginRight","marginBottom","marginLeft","backgroundPositionX","backgroundPositionY"]);function E(t,e){for(let i=0;i<t.length;i++)"number"==typeof t[i]&&v.has(e)&&(t[i]=t[i]+"px")}function R(t,e){const i=window.getComputedStyle(t);return r(e)?i.getPropertyValue(e):i[e]}function S(t,e,n,s){const a=function(t,e,i){if(t instanceof EventTarget)return[t];if("string"==typeof t){let n=document;e&&(n=e.current);const s=i?.[t]??n.querySelectorAll(t);return s?Array.from(s):[]}return Array.from(t)}(t,s),r=a.length,l=[];for(let t=0;t<r;t++){const s=a[t],o={...n};"function"==typeof o.delay&&(o.delay=o.delay(t,r));for(const t in e){let n=e[t];Array.isArray(n)||(n=[n]);const a={...w(o,t)};a.duration&&(a.duration=i(a.duration)),a.delay&&(a.delay=i(a.delay));const r=A(s),h=b(t,a.pseudoElement||""),u=r.get(h);u&&u.stop(),l.push({map:r,key:h,unresolvedKeyframes:n,options:{...a,element:s,name:t,allowFlatten:!o.type&&!o.ease}})}}for(let t=0;t<l.length;t++){const{unresolvedKeyframes:e,options:i}=l[t],{element:n,name:s,pseudoElement:a}=i;a||null!==e[0]||(e[0]=R(n,s)),o(e),E(e,s),!a&&e.length<2&&e.unshift(R(n,s)),i.keyframes=e}const h=[];for(let t=0;t<l.length;t++){const{map:e,key:i,options:n}=l[t],s=new f(n);e.set(i,s),s.finished.finally((()=>e.delete(i))),h.push(s)}return h}const k=t=>function(e,i,n){return new g(S(e,i,n,t))},F=k();export{F as animateMini,k as createScopedWaapiAnimate};
|
package/dist/types/client.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
|
-
import { b as HTMLElements, D as DOMMotionComponents, c as MotionComponentProps, N as ForwardRefComponent, H as HTMLMotionProps, Q as SVGMotionProps } from '../types.d-
|
|
2
|
+
import { b as HTMLElements, D as DOMMotionComponents, c as MotionComponentProps, N as ForwardRefComponent, H as HTMLMotionProps, Q as SVGMotionProps } from '../types.d-DDSxwf0n.js';
|
|
3
3
|
import * as React from 'react';
|
|
4
4
|
import 'react/jsx-runtime';
|
|
5
5
|
import 'motion-dom';
|
package/dist/types/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
|
-
import { F as FeatureBundle, M as MotionProps, a as MotionConfigContext, H as HTMLMotionProps, b as HTMLElements, G as GenericKeyframesTarget, D as DOMMotionComponents, c as MotionComponentProps, d as HTMLMotionComponents, S as SVGMotionComponents, E as EventInfo, e as FeaturePackages, A as AnimationControls, V as VisualElement, f as AnimationDefinition, g as VisualElementAnimationOptions, I as IProjectionNode, R as ResolvedValues, h as HTMLRenderState } from '../types.d-
|
|
3
|
-
export { U as AnimationLifecycles, z as AnimationProps, k as AnimationType, W as CreateVisualElement, l as DragControls, w as DragElastic, y as DragHandlers, x as DraggableProps, ah as FeatureDefinition, ai as FeatureDefinitions, aj as FeaturePackage, X as FlatTree, n as FocusHandlers, N as ForwardRefComponent, o as HoverHandlers, af as HydratedFeatureDefinition, ag as HydratedFeatureDefinitions, Y as Inertia, Z as Keyframes, _ as KeyframesTarget, L as LayoutProps, ak as LazyFeatureBundle, B as MotionAdvancedProps, C as MotionStyle, J as MotionTransform, $ as None, a0 as Orchestration, p as PanHandlers, P as PanInfo, t as PresenceContext, al as RenderComponent, a1 as Repeat, ae as ResolveKeyframes, a2 as ResolvedKeyframesTarget, a3 as ResolvedSingleTarget, a4 as ResolvedValueTarget, O as SVGAttributesAsMotionValues, Q as SVGMotionProps, i as ScrapeMotionValuesFromProps, a5 as SingleTarget, a6 as Spring, v as SwitchLayoutGroupContext, T as TapHandlers, q as TapInfo, a7 as Target, a8 as TargetAndTransition, a9 as Transition, aa as Tween, ab as ValueTarget, ac as Variant, K as VariantLabels, ad as Variants, j as VisualState, r as createRendererMotionComponent, m as makeUseVisualState, s as optimizedAppearDataAttribute, u as useDragControls } from '../types.d-
|
|
2
|
+
import { F as FeatureBundle, M as MotionProps, a as MotionConfigContext, H as HTMLMotionProps, b as HTMLElements, G as GenericKeyframesTarget, D as DOMMotionComponents, c as MotionComponentProps, d as HTMLMotionComponents, S as SVGMotionComponents, E as EventInfo, e as FeaturePackages, A as AnimationControls, V as VisualElement, f as AnimationDefinition, g as VisualElementAnimationOptions, I as IProjectionNode, R as ResolvedValues, h as HTMLRenderState } from '../types.d-DDSxwf0n.js';
|
|
3
|
+
export { U as AnimationLifecycles, z as AnimationProps, k as AnimationType, W as CreateVisualElement, l as DragControls, w as DragElastic, y as DragHandlers, x as DraggableProps, ah as FeatureDefinition, ai as FeatureDefinitions, aj as FeaturePackage, X as FlatTree, n as FocusHandlers, N as ForwardRefComponent, o as HoverHandlers, af as HydratedFeatureDefinition, ag as HydratedFeatureDefinitions, Y as Inertia, Z as Keyframes, _ as KeyframesTarget, L as LayoutProps, ak as LazyFeatureBundle, B as MotionAdvancedProps, C as MotionStyle, J as MotionTransform, $ as None, a0 as Orchestration, p as PanHandlers, P as PanInfo, t as PresenceContext, al as RenderComponent, a1 as Repeat, ae as ResolveKeyframes, a2 as ResolvedKeyframesTarget, a3 as ResolvedSingleTarget, a4 as ResolvedValueTarget, O as SVGAttributesAsMotionValues, Q as SVGMotionProps, i as ScrapeMotionValuesFromProps, a5 as SingleTarget, a6 as Spring, v as SwitchLayoutGroupContext, T as TapHandlers, q as TapInfo, a7 as Target, a8 as TargetAndTransition, a9 as Transition, aa as Tween, ab as ValueTarget, ac as Variant, K as VariantLabels, ad as Variants, j as VisualState, r as createRendererMotionComponent, m as makeUseVisualState, s as optimizedAppearDataAttribute, u as useDragControls } from '../types.d-DDSxwf0n.js';
|
|
4
4
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
5
5
|
import * as React$1 from 'react';
|
|
6
6
|
import { useEffect, RefObject } from 'react';
|
|
@@ -1027,26 +1027,17 @@ type SwitchLayoutGroupContext = SwitchLayoutGroup & InitialPromotionConfig;
|
|
|
1027
1027
|
*/
|
|
1028
1028
|
declare const SwitchLayoutGroupContext: React$1.Context<SwitchLayoutGroupContext>;
|
|
1029
1029
|
|
|
1030
|
-
interface OnUpdateSettings<Instance, RenderState> {
|
|
1031
|
-
props: MotionProps;
|
|
1032
|
-
prevProps?: MotionProps;
|
|
1033
|
-
current: Instance | null;
|
|
1034
|
-
renderState: RenderState;
|
|
1035
|
-
latestValues: ResolvedValues;
|
|
1036
|
-
}
|
|
1037
1030
|
interface VisualState<Instance, RenderState> {
|
|
1038
1031
|
renderState: RenderState;
|
|
1039
1032
|
latestValues: ResolvedValues;
|
|
1040
|
-
onUpdate?: (settings: OnUpdateSettings<Instance, RenderState>) => void;
|
|
1041
1033
|
onMount?: (instance: Instance) => void;
|
|
1042
1034
|
}
|
|
1043
1035
|
type UseVisualState<Instance, RenderState> = (props: MotionProps, isStatic: boolean) => VisualState<Instance, RenderState>;
|
|
1044
|
-
interface UseVisualStateConfig<
|
|
1036
|
+
interface UseVisualStateConfig<RenderState> {
|
|
1045
1037
|
scrapeMotionValuesFromProps: ScrapeMotionValuesFromProps;
|
|
1046
1038
|
createRenderState: () => RenderState;
|
|
1047
|
-
onUpdate?: (settings: OnUpdateSettings<Instance, RenderState>) => void;
|
|
1048
1039
|
}
|
|
1049
|
-
declare const makeUseVisualState: <I, RS>(config: UseVisualStateConfig<
|
|
1040
|
+
declare const makeUseVisualState: <I, RS>(config: UseVisualStateConfig<RS>) => UseVisualState<I, RS>;
|
|
1050
1041
|
|
|
1051
1042
|
type ScrapeMotionValuesFromProps = (props: MotionProps, prevProps: MotionProps, visualElement?: VisualElement) => {
|
|
1052
1043
|
[key: string]: MotionValue | string | number;
|
|
@@ -1526,7 +1517,6 @@ declare abstract class VisualElement<Instance = unknown, RenderState = unknown,
|
|
|
1526
1517
|
* VisualElement.on(), but only one of those can be defined via the onUpdate prop.
|
|
1527
1518
|
*/
|
|
1528
1519
|
private propEventSubscriptions;
|
|
1529
|
-
private onUpdate?;
|
|
1530
1520
|
constructor({ parent, props, presenceContext, reducedMotionConfig, blockInitialAnimation, visualState, }: VisualElementOptions<Instance, RenderState>, options?: Options);
|
|
1531
1521
|
mount(instance: Instance): void;
|
|
1532
1522
|
unmount(): void;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "framer-motion",
|
|
3
|
-
"version": "12.
|
|
3
|
+
"version": "12.9.0",
|
|
4
4
|
"description": "A simple and powerful JavaScript animation library",
|
|
5
5
|
"main": "dist/cjs/index.js",
|
|
6
6
|
"module": "dist/es/index.mjs",
|
|
@@ -87,8 +87,8 @@
|
|
|
87
87
|
"measure": "rollup -c ./rollup.size.config.mjs"
|
|
88
88
|
},
|
|
89
89
|
"dependencies": {
|
|
90
|
-
"motion-dom": "^12.
|
|
91
|
-
"motion-utils": "^12.
|
|
90
|
+
"motion-dom": "^12.9.0",
|
|
91
|
+
"motion-utils": "^12.8.3",
|
|
92
92
|
"tslib": "^2.4.0"
|
|
93
93
|
},
|
|
94
94
|
"devDependencies": {
|
|
@@ -142,5 +142,5 @@
|
|
|
142
142
|
"maxSize": "2.26 kB"
|
|
143
143
|
}
|
|
144
144
|
],
|
|
145
|
-
"gitHead": "
|
|
145
|
+
"gitHead": "cbc2fc41e0beb97f133ad53e509b1595e9124610"
|
|
146
146
|
}
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
function updateSVGDimensions(instance, renderState) {
|
|
2
|
-
try {
|
|
3
|
-
renderState.dimensions =
|
|
4
|
-
typeof instance.getBBox === "function"
|
|
5
|
-
? instance.getBBox()
|
|
6
|
-
: instance.getBoundingClientRect();
|
|
7
|
-
}
|
|
8
|
-
catch (e) {
|
|
9
|
-
// Most likely trying to measure an unrendered element under Firefox
|
|
10
|
-
renderState.dimensions = {
|
|
11
|
-
x: 0,
|
|
12
|
-
y: 0,
|
|
13
|
-
width: 0,
|
|
14
|
-
height: 0,
|
|
15
|
-
};
|
|
16
|
-
}
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
export { updateSVGDimensions };
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import { px } from 'motion-dom';
|
|
2
|
-
|
|
3
|
-
function calcOrigin(origin, offset, size) {
|
|
4
|
-
return typeof origin === "string"
|
|
5
|
-
? origin
|
|
6
|
-
: px.transform(offset + size * origin);
|
|
7
|
-
}
|
|
8
|
-
/**
|
|
9
|
-
* The SVG transform origin defaults are different to CSS and is less intuitive,
|
|
10
|
-
* so we use the measured dimensions of the SVG to reconcile these.
|
|
11
|
-
*/
|
|
12
|
-
function calcSVGTransformOrigin(dimensions, originX, originY) {
|
|
13
|
-
const pxOriginX = calcOrigin(originX, dimensions.x, dimensions.width);
|
|
14
|
-
const pxOriginY = calcOrigin(originY, dimensions.y, dimensions.height);
|
|
15
|
-
return `${pxOriginX} ${pxOriginY}`;
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
export { calcSVGTransformOrigin };
|