motion 12.14.0 → 12.16.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/index.js +289 -201
- package/dist/cjs/react-client.js +26 -25
- package/dist/es/framer-motion/dist/es/projection/node/create-projection-node.mjs +1 -0
- package/dist/es/framer-motion/dist/es/render/dom/scroll/track.mjs +1 -1
- package/dist/es/motion/lib/index.mjs +4 -0
- package/dist/es/motion/lib/react.mjs +4 -0
- package/dist/es/motion-dom/dist/es/effects/attr/index.mjs +41 -0
- package/dist/es/motion-dom/dist/es/effects/prop/index.mjs +9 -0
- package/dist/es/motion-dom/dist/es/effects/style/index.mjs +6 -0
- package/dist/es/motion-dom/dist/es/effects/svg/index.mjs +41 -0
- package/dist/es/motion-dom/dist/es/render/dom/utils/camel-to-dash.mjs +5 -0
- package/dist/es/{framer-motion/dist/es/render/dom → motion-dom/dist/es}/resize/handle-element.mjs +17 -18
- package/dist/es/{framer-motion/dist/es/render/dom → motion-dom/dist/es}/resize/handle-window.mjs +9 -8
- package/dist/motion.dev.js +289 -201
- package/dist/motion.js +1 -1
- package/package.json +3 -3
- /package/dist/es/{framer-motion/dist/es/render/dom → motion-dom/dist/es}/resize/index.mjs +0 -0
package/dist/cjs/index.js
CHANGED
|
@@ -3347,6 +3347,152 @@ const acceleratedValues = new Set([
|
|
|
3347
3347
|
// "background-color"
|
|
3348
3348
|
]);
|
|
3349
3349
|
|
|
3350
|
+
function camelToDash$1(str) {
|
|
3351
|
+
return str.replace(/([A-Z])/g, (match) => `-${match.toLowerCase()}`);
|
|
3352
|
+
}
|
|
3353
|
+
|
|
3354
|
+
function resolveElements(elementOrSelector, scope, selectorCache) {
|
|
3355
|
+
if (elementOrSelector instanceof EventTarget) {
|
|
3356
|
+
return [elementOrSelector];
|
|
3357
|
+
}
|
|
3358
|
+
else if (typeof elementOrSelector === "string") {
|
|
3359
|
+
let root = document;
|
|
3360
|
+
if (scope) {
|
|
3361
|
+
root = scope.current;
|
|
3362
|
+
}
|
|
3363
|
+
const elements = selectorCache?.[elementOrSelector] ??
|
|
3364
|
+
root.querySelectorAll(elementOrSelector);
|
|
3365
|
+
return elements ? Array.from(elements) : [];
|
|
3366
|
+
}
|
|
3367
|
+
return Array.from(elementOrSelector);
|
|
3368
|
+
}
|
|
3369
|
+
|
|
3370
|
+
function createSelectorEffect(subjectEffect) {
|
|
3371
|
+
return (subject, values) => {
|
|
3372
|
+
const elements = resolveElements(subject);
|
|
3373
|
+
const subscriptions = [];
|
|
3374
|
+
for (const element of elements) {
|
|
3375
|
+
const remove = subjectEffect(element, values);
|
|
3376
|
+
subscriptions.push(remove);
|
|
3377
|
+
}
|
|
3378
|
+
return () => {
|
|
3379
|
+
for (const remove of subscriptions)
|
|
3380
|
+
remove();
|
|
3381
|
+
};
|
|
3382
|
+
};
|
|
3383
|
+
}
|
|
3384
|
+
|
|
3385
|
+
/**
|
|
3386
|
+
* Provided a value and a ValueType, returns the value as that value type.
|
|
3387
|
+
*/
|
|
3388
|
+
const getValueAsType = (value, type) => {
|
|
3389
|
+
return type && typeof value === "number"
|
|
3390
|
+
? type.transform(value)
|
|
3391
|
+
: value;
|
|
3392
|
+
};
|
|
3393
|
+
|
|
3394
|
+
class MotionValueState {
|
|
3395
|
+
constructor() {
|
|
3396
|
+
this.latest = {};
|
|
3397
|
+
this.values = new Map();
|
|
3398
|
+
}
|
|
3399
|
+
set(name, value, render, computed, useDefaultValueType = true) {
|
|
3400
|
+
const existingValue = this.values.get(name);
|
|
3401
|
+
if (existingValue) {
|
|
3402
|
+
existingValue.onRemove();
|
|
3403
|
+
}
|
|
3404
|
+
const onChange = () => {
|
|
3405
|
+
const v = value.get();
|
|
3406
|
+
if (useDefaultValueType) {
|
|
3407
|
+
this.latest[name] = getValueAsType(v, numberValueTypes[name]);
|
|
3408
|
+
}
|
|
3409
|
+
else {
|
|
3410
|
+
this.latest[name] = v;
|
|
3411
|
+
}
|
|
3412
|
+
render && frame.render(render);
|
|
3413
|
+
};
|
|
3414
|
+
onChange();
|
|
3415
|
+
const cancelOnChange = value.on("change", onChange);
|
|
3416
|
+
computed && value.addDependent(computed);
|
|
3417
|
+
const remove = () => {
|
|
3418
|
+
cancelOnChange();
|
|
3419
|
+
render && cancelFrame(render);
|
|
3420
|
+
this.values.delete(name);
|
|
3421
|
+
computed && value.removeDependent(computed);
|
|
3422
|
+
};
|
|
3423
|
+
this.values.set(name, { value, onRemove: remove });
|
|
3424
|
+
return remove;
|
|
3425
|
+
}
|
|
3426
|
+
get(name) {
|
|
3427
|
+
return this.values.get(name)?.value;
|
|
3428
|
+
}
|
|
3429
|
+
destroy() {
|
|
3430
|
+
for (const value of this.values.values()) {
|
|
3431
|
+
value.onRemove();
|
|
3432
|
+
}
|
|
3433
|
+
}
|
|
3434
|
+
}
|
|
3435
|
+
|
|
3436
|
+
function createEffect(addValue) {
|
|
3437
|
+
const stateCache = new WeakMap();
|
|
3438
|
+
const subscriptions = [];
|
|
3439
|
+
return (subject, values) => {
|
|
3440
|
+
const state = stateCache.get(subject) ?? new MotionValueState();
|
|
3441
|
+
stateCache.set(subject, state);
|
|
3442
|
+
for (const key in values) {
|
|
3443
|
+
const value = values[key];
|
|
3444
|
+
const remove = addValue(subject, state, key, value);
|
|
3445
|
+
subscriptions.push(remove);
|
|
3446
|
+
}
|
|
3447
|
+
return () => {
|
|
3448
|
+
for (const cancel of subscriptions)
|
|
3449
|
+
cancel();
|
|
3450
|
+
};
|
|
3451
|
+
};
|
|
3452
|
+
}
|
|
3453
|
+
|
|
3454
|
+
function canSetAsProperty(element, name) {
|
|
3455
|
+
if (!(name in element))
|
|
3456
|
+
return false;
|
|
3457
|
+
const descriptor = Object.getOwnPropertyDescriptor(Object.getPrototypeOf(element), name) ||
|
|
3458
|
+
Object.getOwnPropertyDescriptor(element, name);
|
|
3459
|
+
// Check if it has a setter
|
|
3460
|
+
return descriptor && typeof descriptor.set === "function";
|
|
3461
|
+
}
|
|
3462
|
+
const addAttrValue = (element, state, key, value) => {
|
|
3463
|
+
const isProp = canSetAsProperty(element, key);
|
|
3464
|
+
const name = isProp
|
|
3465
|
+
? key
|
|
3466
|
+
: key.startsWith("data") || key.startsWith("aria")
|
|
3467
|
+
? camelToDash$1(key)
|
|
3468
|
+
: key;
|
|
3469
|
+
/**
|
|
3470
|
+
* Set attribute directly via property if available
|
|
3471
|
+
*/
|
|
3472
|
+
const render = isProp
|
|
3473
|
+
? () => {
|
|
3474
|
+
element[name] = state.latest[key];
|
|
3475
|
+
}
|
|
3476
|
+
: () => {
|
|
3477
|
+
const v = state.latest[key];
|
|
3478
|
+
if (v === null || v === undefined) {
|
|
3479
|
+
element.removeAttribute(name);
|
|
3480
|
+
}
|
|
3481
|
+
else {
|
|
3482
|
+
element.setAttribute(name, String(v));
|
|
3483
|
+
}
|
|
3484
|
+
};
|
|
3485
|
+
return state.set(key, value, render);
|
|
3486
|
+
};
|
|
3487
|
+
const attrEffect = /*@__PURE__*/ createSelectorEffect(
|
|
3488
|
+
/*@__PURE__*/ createEffect(addAttrValue));
|
|
3489
|
+
|
|
3490
|
+
const propEffect = /*@__PURE__*/ createEffect((subject, state, key, value) => {
|
|
3491
|
+
return state.set(key, value, () => {
|
|
3492
|
+
subject[key] = state.latest[key];
|
|
3493
|
+
}, undefined, false);
|
|
3494
|
+
});
|
|
3495
|
+
|
|
3350
3496
|
/**
|
|
3351
3497
|
* Maximum time between the value of two frames, beyond which we
|
|
3352
3498
|
* assume the velocity has since been 0.
|
|
@@ -3669,106 +3815,6 @@ function motionValue(init, options) {
|
|
|
3669
3815
|
return new MotionValue(init, options);
|
|
3670
3816
|
}
|
|
3671
3817
|
|
|
3672
|
-
function resolveElements(elementOrSelector, scope, selectorCache) {
|
|
3673
|
-
if (elementOrSelector instanceof EventTarget) {
|
|
3674
|
-
return [elementOrSelector];
|
|
3675
|
-
}
|
|
3676
|
-
else if (typeof elementOrSelector === "string") {
|
|
3677
|
-
let root = document;
|
|
3678
|
-
if (scope) {
|
|
3679
|
-
root = scope.current;
|
|
3680
|
-
}
|
|
3681
|
-
const elements = selectorCache?.[elementOrSelector] ??
|
|
3682
|
-
root.querySelectorAll(elementOrSelector);
|
|
3683
|
-
return elements ? Array.from(elements) : [];
|
|
3684
|
-
}
|
|
3685
|
-
return Array.from(elementOrSelector);
|
|
3686
|
-
}
|
|
3687
|
-
|
|
3688
|
-
function createSelectorEffect(subjectEffect) {
|
|
3689
|
-
return (subject, values) => {
|
|
3690
|
-
const elements = resolveElements(subject);
|
|
3691
|
-
const subscriptions = [];
|
|
3692
|
-
for (const element of elements) {
|
|
3693
|
-
const remove = subjectEffect(element, values);
|
|
3694
|
-
subscriptions.push(remove);
|
|
3695
|
-
}
|
|
3696
|
-
return () => {
|
|
3697
|
-
for (const remove of subscriptions)
|
|
3698
|
-
remove();
|
|
3699
|
-
};
|
|
3700
|
-
};
|
|
3701
|
-
}
|
|
3702
|
-
|
|
3703
|
-
/**
|
|
3704
|
-
* Provided a value and a ValueType, returns the value as that value type.
|
|
3705
|
-
*/
|
|
3706
|
-
const getValueAsType = (value, type) => {
|
|
3707
|
-
return type && typeof value === "number"
|
|
3708
|
-
? type.transform(value)
|
|
3709
|
-
: value;
|
|
3710
|
-
};
|
|
3711
|
-
|
|
3712
|
-
class MotionValueState {
|
|
3713
|
-
constructor() {
|
|
3714
|
-
this.latest = {};
|
|
3715
|
-
this.values = new Map();
|
|
3716
|
-
}
|
|
3717
|
-
set(name, value, render, computed, useDefaultValueType = true) {
|
|
3718
|
-
const existingValue = this.values.get(name);
|
|
3719
|
-
if (existingValue) {
|
|
3720
|
-
existingValue.onRemove();
|
|
3721
|
-
}
|
|
3722
|
-
const onChange = () => {
|
|
3723
|
-
const v = value.get();
|
|
3724
|
-
if (useDefaultValueType) {
|
|
3725
|
-
this.latest[name] = getValueAsType(v, numberValueTypes[name]);
|
|
3726
|
-
}
|
|
3727
|
-
else {
|
|
3728
|
-
this.latest[name] = v;
|
|
3729
|
-
}
|
|
3730
|
-
render && frame.render(render);
|
|
3731
|
-
};
|
|
3732
|
-
onChange();
|
|
3733
|
-
const cancelOnChange = value.on("change", onChange);
|
|
3734
|
-
computed && value.addDependent(computed);
|
|
3735
|
-
const remove = () => {
|
|
3736
|
-
cancelOnChange();
|
|
3737
|
-
render && cancelFrame(render);
|
|
3738
|
-
this.values.delete(name);
|
|
3739
|
-
computed && value.removeDependent(computed);
|
|
3740
|
-
};
|
|
3741
|
-
this.values.set(name, { value, onRemove: remove });
|
|
3742
|
-
return remove;
|
|
3743
|
-
}
|
|
3744
|
-
get(name) {
|
|
3745
|
-
return this.values.get(name)?.value;
|
|
3746
|
-
}
|
|
3747
|
-
destroy() {
|
|
3748
|
-
for (const value of this.values.values()) {
|
|
3749
|
-
value.onRemove();
|
|
3750
|
-
}
|
|
3751
|
-
}
|
|
3752
|
-
}
|
|
3753
|
-
|
|
3754
|
-
function createEffect(addValue) {
|
|
3755
|
-
const stateCache = new WeakMap();
|
|
3756
|
-
const subscriptions = [];
|
|
3757
|
-
return (subject, values) => {
|
|
3758
|
-
const state = stateCache.get(subject) ?? new MotionValueState();
|
|
3759
|
-
stateCache.set(subject, state);
|
|
3760
|
-
for (const key in values) {
|
|
3761
|
-
const value = values[key];
|
|
3762
|
-
const remove = addValue(subject, state, key, value);
|
|
3763
|
-
subscriptions.push(remove);
|
|
3764
|
-
}
|
|
3765
|
-
return () => {
|
|
3766
|
-
for (const cancel of subscriptions)
|
|
3767
|
-
cancel();
|
|
3768
|
-
};
|
|
3769
|
-
};
|
|
3770
|
-
}
|
|
3771
|
-
|
|
3772
3818
|
const translateAlias$1 = {
|
|
3773
3819
|
x: "translateX",
|
|
3774
3820
|
y: "translateY",
|
|
@@ -3810,6 +3856,11 @@ const addStyleValue = (element, state, key, value) => {
|
|
|
3810
3856
|
let computed = undefined;
|
|
3811
3857
|
if (transformProps.has(key)) {
|
|
3812
3858
|
if (!state.get("transform")) {
|
|
3859
|
+
// If this is an HTML element, we need to set the transform-box to fill-box
|
|
3860
|
+
// to normalise the transform relative to the element's bounding box
|
|
3861
|
+
if (!isHTMLElement(element) && !state.get("transformBox")) {
|
|
3862
|
+
addStyleValue(element, state, "transformBox", new MotionValue("fill-box"));
|
|
3863
|
+
}
|
|
3813
3864
|
state.set("transform", new MotionValue("none"), () => {
|
|
3814
3865
|
element.style.transform = buildTransform$1(state);
|
|
3815
3866
|
});
|
|
@@ -3842,6 +3893,38 @@ const addStyleValue = (element, state, key, value) => {
|
|
|
3842
3893
|
const styleEffect = /*@__PURE__*/ createSelectorEffect(
|
|
3843
3894
|
/*@__PURE__*/ createEffect(addStyleValue));
|
|
3844
3895
|
|
|
3896
|
+
const toPx = px.transform;
|
|
3897
|
+
function addSVGPathValue(element, state, key, value) {
|
|
3898
|
+
frame.render(() => element.setAttribute("pathLength", "1"));
|
|
3899
|
+
if (key === "pathOffset") {
|
|
3900
|
+
return state.set(key, value, () => element.setAttribute("stroke-dashoffset", toPx(-state.latest[key])));
|
|
3901
|
+
}
|
|
3902
|
+
else {
|
|
3903
|
+
if (!state.get("stroke-dasharray")) {
|
|
3904
|
+
state.set("stroke-dasharray", new MotionValue("1 1"), () => {
|
|
3905
|
+
const { pathLength = 1, pathSpacing } = state.latest;
|
|
3906
|
+
element.setAttribute("stroke-dasharray", `${toPx(pathLength)} ${toPx(pathSpacing ?? 1 - Number(pathLength))}`);
|
|
3907
|
+
});
|
|
3908
|
+
}
|
|
3909
|
+
return state.set(key, value, undefined, state.get("stroke-dasharray"));
|
|
3910
|
+
}
|
|
3911
|
+
}
|
|
3912
|
+
const addSVGValue = (element, state, key, value) => {
|
|
3913
|
+
if (key.startsWith("path")) {
|
|
3914
|
+
return addSVGPathValue(element, state, key, value);
|
|
3915
|
+
}
|
|
3916
|
+
else if (key.startsWith("attr")) {
|
|
3917
|
+
return addAttrValue(element, state, convertAttrKey(key), value);
|
|
3918
|
+
}
|
|
3919
|
+
const handler = key in element.style ? addStyleValue : addAttrValue;
|
|
3920
|
+
return handler(element, state, key, value);
|
|
3921
|
+
};
|
|
3922
|
+
const svgEffect = /*@__PURE__*/ createSelectorEffect(
|
|
3923
|
+
/*@__PURE__*/ createEffect(addSVGValue));
|
|
3924
|
+
function convertAttrKey(key) {
|
|
3925
|
+
return key.replace(/^attr([A-Z])/, (_, firstChar) => firstChar.toLowerCase());
|
|
3926
|
+
}
|
|
3927
|
+
|
|
3845
3928
|
const { schedule: microtask, cancel: cancelMicrotask } =
|
|
3846
3929
|
/* @__PURE__ */ createRenderBatcher(queueMicrotask, false);
|
|
3847
3930
|
|
|
@@ -4088,6 +4171,107 @@ function getComputedStyle$2(element, name) {
|
|
|
4088
4171
|
: computedStyle[name];
|
|
4089
4172
|
}
|
|
4090
4173
|
|
|
4174
|
+
/**
|
|
4175
|
+
* Checks if an element is an SVG element in a way
|
|
4176
|
+
* that works across iframes
|
|
4177
|
+
*/
|
|
4178
|
+
function isSVGElement(element) {
|
|
4179
|
+
return isObject(element) && "ownerSVGElement" in element;
|
|
4180
|
+
}
|
|
4181
|
+
|
|
4182
|
+
const resizeHandlers = new WeakMap();
|
|
4183
|
+
let observer;
|
|
4184
|
+
const getSize = (borderBoxAxis, svgAxis, htmlAxis) => (target, borderBoxSize) => {
|
|
4185
|
+
if (borderBoxSize && borderBoxSize[0]) {
|
|
4186
|
+
return borderBoxSize[0][(borderBoxAxis + "Size")];
|
|
4187
|
+
}
|
|
4188
|
+
else if (isSVGElement(target) && "getBBox" in target) {
|
|
4189
|
+
return target.getBBox()[svgAxis];
|
|
4190
|
+
}
|
|
4191
|
+
else {
|
|
4192
|
+
return target[htmlAxis];
|
|
4193
|
+
}
|
|
4194
|
+
};
|
|
4195
|
+
const getWidth = /*@__PURE__*/ getSize("inline", "width", "offsetWidth");
|
|
4196
|
+
const getHeight = /*@__PURE__*/ getSize("block", "height", "offsetHeight");
|
|
4197
|
+
function notifyTarget({ target, borderBoxSize }) {
|
|
4198
|
+
resizeHandlers.get(target)?.forEach((handler) => {
|
|
4199
|
+
handler(target, {
|
|
4200
|
+
get width() {
|
|
4201
|
+
return getWidth(target, borderBoxSize);
|
|
4202
|
+
},
|
|
4203
|
+
get height() {
|
|
4204
|
+
return getHeight(target, borderBoxSize);
|
|
4205
|
+
},
|
|
4206
|
+
});
|
|
4207
|
+
});
|
|
4208
|
+
}
|
|
4209
|
+
function notifyAll(entries) {
|
|
4210
|
+
entries.forEach(notifyTarget);
|
|
4211
|
+
}
|
|
4212
|
+
function createResizeObserver() {
|
|
4213
|
+
if (typeof ResizeObserver === "undefined")
|
|
4214
|
+
return;
|
|
4215
|
+
observer = new ResizeObserver(notifyAll);
|
|
4216
|
+
}
|
|
4217
|
+
function resizeElement(target, handler) {
|
|
4218
|
+
if (!observer)
|
|
4219
|
+
createResizeObserver();
|
|
4220
|
+
const elements = resolveElements(target);
|
|
4221
|
+
elements.forEach((element) => {
|
|
4222
|
+
let elementHandlers = resizeHandlers.get(element);
|
|
4223
|
+
if (!elementHandlers) {
|
|
4224
|
+
elementHandlers = new Set();
|
|
4225
|
+
resizeHandlers.set(element, elementHandlers);
|
|
4226
|
+
}
|
|
4227
|
+
elementHandlers.add(handler);
|
|
4228
|
+
observer?.observe(element);
|
|
4229
|
+
});
|
|
4230
|
+
return () => {
|
|
4231
|
+
elements.forEach((element) => {
|
|
4232
|
+
const elementHandlers = resizeHandlers.get(element);
|
|
4233
|
+
elementHandlers?.delete(handler);
|
|
4234
|
+
if (!elementHandlers?.size) {
|
|
4235
|
+
observer?.unobserve(element);
|
|
4236
|
+
}
|
|
4237
|
+
});
|
|
4238
|
+
};
|
|
4239
|
+
}
|
|
4240
|
+
|
|
4241
|
+
const windowCallbacks = new Set();
|
|
4242
|
+
let windowResizeHandler;
|
|
4243
|
+
function createWindowResizeHandler() {
|
|
4244
|
+
windowResizeHandler = () => {
|
|
4245
|
+
const info = {
|
|
4246
|
+
get width() {
|
|
4247
|
+
return window.innerWidth;
|
|
4248
|
+
},
|
|
4249
|
+
get height() {
|
|
4250
|
+
return window.innerHeight;
|
|
4251
|
+
},
|
|
4252
|
+
};
|
|
4253
|
+
windowCallbacks.forEach((callback) => callback(info));
|
|
4254
|
+
};
|
|
4255
|
+
window.addEventListener("resize", windowResizeHandler);
|
|
4256
|
+
}
|
|
4257
|
+
function resizeWindow(callback) {
|
|
4258
|
+
windowCallbacks.add(callback);
|
|
4259
|
+
if (!windowResizeHandler)
|
|
4260
|
+
createWindowResizeHandler();
|
|
4261
|
+
return () => {
|
|
4262
|
+
windowCallbacks.delete(callback);
|
|
4263
|
+
if (!windowCallbacks.size &&
|
|
4264
|
+
typeof windowResizeHandler === "function") {
|
|
4265
|
+
window.removeEventListener("resize", windowResizeHandler);
|
|
4266
|
+
windowResizeHandler = undefined;
|
|
4267
|
+
}
|
|
4268
|
+
};
|
|
4269
|
+
}
|
|
4270
|
+
|
|
4271
|
+
function resize(a, b) {
|
|
4272
|
+
return typeof a === "function" ? resizeWindow(a) : resizeElement(a, b);
|
|
4273
|
+
}
|
|
4274
|
+
|
|
4091
4275
|
function observeTimeline(update, timeline) {
|
|
4092
4276
|
let prevProgress;
|
|
4093
4277
|
const onFrame = () => {
|
|
@@ -4215,14 +4399,6 @@ function recordStats() {
|
|
|
4215
4399
|
return reportStats;
|
|
4216
4400
|
}
|
|
4217
4401
|
|
|
4218
|
-
/**
|
|
4219
|
-
* Checks if an element is an SVG element in a way
|
|
4220
|
-
* that works across iframes
|
|
4221
|
-
*/
|
|
4222
|
-
function isSVGElement(element) {
|
|
4223
|
-
return isObject(element) && "ownerSVGElement" in element;
|
|
4224
|
-
}
|
|
4225
|
-
|
|
4226
4402
|
/**
|
|
4227
4403
|
* Checks if an element is specifically an SVGSVGElement (the root SVG element)
|
|
4228
4404
|
* in a way that works across iframes
|
|
@@ -6665,99 +6841,6 @@ const createScopedWaapiAnimate = (scope) => {
|
|
|
6665
6841
|
};
|
|
6666
6842
|
const animateMini = /*@__PURE__*/ createScopedWaapiAnimate();
|
|
6667
6843
|
|
|
6668
|
-
const resizeHandlers = new WeakMap();
|
|
6669
|
-
let observer;
|
|
6670
|
-
function getElementSize(target, borderBoxSize) {
|
|
6671
|
-
if (borderBoxSize) {
|
|
6672
|
-
const { inlineSize, blockSize } = borderBoxSize[0];
|
|
6673
|
-
return { width: inlineSize, height: blockSize };
|
|
6674
|
-
}
|
|
6675
|
-
else if (isSVGElement(target) && "getBBox" in target) {
|
|
6676
|
-
return target.getBBox();
|
|
6677
|
-
}
|
|
6678
|
-
else {
|
|
6679
|
-
return {
|
|
6680
|
-
width: target.offsetWidth,
|
|
6681
|
-
height: target.offsetHeight,
|
|
6682
|
-
};
|
|
6683
|
-
}
|
|
6684
|
-
}
|
|
6685
|
-
function notifyTarget({ target, contentRect, borderBoxSize, }) {
|
|
6686
|
-
resizeHandlers.get(target)?.forEach((handler) => {
|
|
6687
|
-
handler({
|
|
6688
|
-
target,
|
|
6689
|
-
contentSize: contentRect,
|
|
6690
|
-
get size() {
|
|
6691
|
-
return getElementSize(target, borderBoxSize);
|
|
6692
|
-
},
|
|
6693
|
-
});
|
|
6694
|
-
});
|
|
6695
|
-
}
|
|
6696
|
-
function notifyAll(entries) {
|
|
6697
|
-
entries.forEach(notifyTarget);
|
|
6698
|
-
}
|
|
6699
|
-
function createResizeObserver() {
|
|
6700
|
-
if (typeof ResizeObserver === "undefined")
|
|
6701
|
-
return;
|
|
6702
|
-
observer = new ResizeObserver(notifyAll);
|
|
6703
|
-
}
|
|
6704
|
-
function resizeElement(target, handler) {
|
|
6705
|
-
if (!observer)
|
|
6706
|
-
createResizeObserver();
|
|
6707
|
-
const elements = resolveElements(target);
|
|
6708
|
-
elements.forEach((element) => {
|
|
6709
|
-
let elementHandlers = resizeHandlers.get(element);
|
|
6710
|
-
if (!elementHandlers) {
|
|
6711
|
-
elementHandlers = new Set();
|
|
6712
|
-
resizeHandlers.set(element, elementHandlers);
|
|
6713
|
-
}
|
|
6714
|
-
elementHandlers.add(handler);
|
|
6715
|
-
observer?.observe(element);
|
|
6716
|
-
});
|
|
6717
|
-
return () => {
|
|
6718
|
-
elements.forEach((element) => {
|
|
6719
|
-
const elementHandlers = resizeHandlers.get(element);
|
|
6720
|
-
elementHandlers?.delete(handler);
|
|
6721
|
-
if (!elementHandlers?.size) {
|
|
6722
|
-
observer?.unobserve(element);
|
|
6723
|
-
}
|
|
6724
|
-
});
|
|
6725
|
-
};
|
|
6726
|
-
}
|
|
6727
|
-
|
|
6728
|
-
const windowCallbacks = new Set();
|
|
6729
|
-
let windowResizeHandler;
|
|
6730
|
-
function createWindowResizeHandler() {
|
|
6731
|
-
windowResizeHandler = () => {
|
|
6732
|
-
const size = {
|
|
6733
|
-
width: window.innerWidth,
|
|
6734
|
-
height: window.innerHeight,
|
|
6735
|
-
};
|
|
6736
|
-
const info = {
|
|
6737
|
-
target: window,
|
|
6738
|
-
size,
|
|
6739
|
-
contentSize: size,
|
|
6740
|
-
};
|
|
6741
|
-
windowCallbacks.forEach((callback) => callback(info));
|
|
6742
|
-
};
|
|
6743
|
-
window.addEventListener("resize", windowResizeHandler);
|
|
6744
|
-
}
|
|
6745
|
-
function resizeWindow(callback) {
|
|
6746
|
-
windowCallbacks.add(callback);
|
|
6747
|
-
if (!windowResizeHandler)
|
|
6748
|
-
createWindowResizeHandler();
|
|
6749
|
-
return () => {
|
|
6750
|
-
windowCallbacks.delete(callback);
|
|
6751
|
-
if (!windowCallbacks.size && windowResizeHandler) {
|
|
6752
|
-
windowResizeHandler = undefined;
|
|
6753
|
-
}
|
|
6754
|
-
};
|
|
6755
|
-
}
|
|
6756
|
-
|
|
6757
|
-
function resize(a, b) {
|
|
6758
|
-
return typeof a === "function" ? resizeWindow(a) : resizeElement(a, b);
|
|
6759
|
-
}
|
|
6760
|
-
|
|
6761
6844
|
/**
|
|
6762
6845
|
* A time in milliseconds, beyond which we consider the scroll velocity to be 0.
|
|
6763
6846
|
*/
|
|
@@ -7289,6 +7372,7 @@ exports.SubscriptionManager = SubscriptionManager;
|
|
|
7289
7372
|
exports.ViewTransitionBuilder = ViewTransitionBuilder;
|
|
7290
7373
|
exports.acceleratedValues = acceleratedValues;
|
|
7291
7374
|
exports.activeAnimations = activeAnimations;
|
|
7375
|
+
exports.addAttrValue = addAttrValue;
|
|
7292
7376
|
exports.addStyleValue = addStyleValue;
|
|
7293
7377
|
exports.addUniqueItem = addUniqueItem;
|
|
7294
7378
|
exports.alpha = alpha;
|
|
@@ -7301,6 +7385,7 @@ exports.animationMapKey = animationMapKey;
|
|
|
7301
7385
|
exports.anticipate = anticipate;
|
|
7302
7386
|
exports.applyPxDefaults = applyPxDefaults;
|
|
7303
7387
|
exports.attachSpring = attachSpring;
|
|
7388
|
+
exports.attrEffect = attrEffect;
|
|
7304
7389
|
exports.backIn = backIn;
|
|
7305
7390
|
exports.backInOut = backInOut;
|
|
7306
7391
|
exports.backOut = backOut;
|
|
@@ -7409,10 +7494,12 @@ exports.positionalKeys = positionalKeys;
|
|
|
7409
7494
|
exports.press = press;
|
|
7410
7495
|
exports.progress = progress;
|
|
7411
7496
|
exports.progressPercentage = progressPercentage;
|
|
7497
|
+
exports.propEffect = propEffect;
|
|
7412
7498
|
exports.px = px;
|
|
7413
7499
|
exports.readTransformValue = readTransformValue;
|
|
7414
7500
|
exports.recordStats = recordStats;
|
|
7415
7501
|
exports.removeItem = removeItem;
|
|
7502
|
+
exports.resize = resize;
|
|
7416
7503
|
exports.resolveElements = resolveElements;
|
|
7417
7504
|
exports.reverseEasing = reverseEasing;
|
|
7418
7505
|
exports.rgbUnit = rgbUnit;
|
|
@@ -7436,6 +7523,7 @@ exports.supportsFlags = supportsFlags;
|
|
|
7436
7523
|
exports.supportsLinearEasing = supportsLinearEasing;
|
|
7437
7524
|
exports.supportsPartialKeyframes = supportsPartialKeyframes;
|
|
7438
7525
|
exports.supportsScrollTimeline = supportsScrollTimeline;
|
|
7526
|
+
exports.svgEffect = svgEffect;
|
|
7439
7527
|
exports.sync = sync;
|
|
7440
7528
|
exports.testValueType = testValueType;
|
|
7441
7529
|
exports.time = time;
|
package/dist/cjs/react-client.js
CHANGED
|
@@ -3168,6 +3168,31 @@ class DOMKeyframesResolver extends KeyframeResolver {
|
|
|
3168
3168
|
}
|
|
3169
3169
|
}
|
|
3170
3170
|
|
|
3171
|
+
function resolveElements(elementOrSelector, scope, selectorCache) {
|
|
3172
|
+
if (elementOrSelector instanceof EventTarget) {
|
|
3173
|
+
return [elementOrSelector];
|
|
3174
|
+
}
|
|
3175
|
+
else if (typeof elementOrSelector === "string") {
|
|
3176
|
+
let root = document;
|
|
3177
|
+
if (scope) {
|
|
3178
|
+
root = scope.current;
|
|
3179
|
+
}
|
|
3180
|
+
const elements = selectorCache?.[elementOrSelector] ??
|
|
3181
|
+
root.querySelectorAll(elementOrSelector);
|
|
3182
|
+
return elements ? Array.from(elements) : [];
|
|
3183
|
+
}
|
|
3184
|
+
return Array.from(elementOrSelector);
|
|
3185
|
+
}
|
|
3186
|
+
|
|
3187
|
+
/**
|
|
3188
|
+
* Provided a value and a ValueType, returns the value as that value type.
|
|
3189
|
+
*/
|
|
3190
|
+
const getValueAsType = (value, type) => {
|
|
3191
|
+
return type && typeof value === "number"
|
|
3192
|
+
? type.transform(value)
|
|
3193
|
+
: value;
|
|
3194
|
+
};
|
|
3195
|
+
|
|
3171
3196
|
/**
|
|
3172
3197
|
* Maximum time between the value of two frames, beyond which we
|
|
3173
3198
|
* assume the velocity has since been 0.
|
|
@@ -3484,31 +3509,6 @@ function motionValue(init, options) {
|
|
|
3484
3509
|
return new MotionValue(init, options);
|
|
3485
3510
|
}
|
|
3486
3511
|
|
|
3487
|
-
function resolveElements(elementOrSelector, scope, selectorCache) {
|
|
3488
|
-
if (elementOrSelector instanceof EventTarget) {
|
|
3489
|
-
return [elementOrSelector];
|
|
3490
|
-
}
|
|
3491
|
-
else if (typeof elementOrSelector === "string") {
|
|
3492
|
-
let root = document;
|
|
3493
|
-
if (scope) {
|
|
3494
|
-
root = scope.current;
|
|
3495
|
-
}
|
|
3496
|
-
const elements = selectorCache?.[elementOrSelector] ??
|
|
3497
|
-
root.querySelectorAll(elementOrSelector);
|
|
3498
|
-
return elements ? Array.from(elements) : [];
|
|
3499
|
-
}
|
|
3500
|
-
return Array.from(elementOrSelector);
|
|
3501
|
-
}
|
|
3502
|
-
|
|
3503
|
-
/**
|
|
3504
|
-
* Provided a value and a ValueType, returns the value as that value type.
|
|
3505
|
-
*/
|
|
3506
|
-
const getValueAsType = (value, type) => {
|
|
3507
|
-
return type && typeof value === "number"
|
|
3508
|
-
? type.transform(value)
|
|
3509
|
-
: value;
|
|
3510
|
-
};
|
|
3511
|
-
|
|
3512
3512
|
const { schedule: microtask, cancel: cancelMicrotask } =
|
|
3513
3513
|
/* @__PURE__ */ createRenderBatcher(queueMicrotask, false);
|
|
3514
3514
|
|
|
@@ -7393,6 +7393,7 @@ function createProjectionNode$1({ attachResizeListener, defaultParent, measureSc
|
|
|
7393
7393
|
this.motionValue || (this.motionValue = motionValue(0));
|
|
7394
7394
|
this.currentAnimation = animateSingleValue(this.motionValue, [0, 1000], {
|
|
7395
7395
|
...options,
|
|
7396
|
+
velocity: 0,
|
|
7396
7397
|
isSync: true,
|
|
7397
7398
|
onUpdate: (latest) => {
|
|
7398
7399
|
this.mixTargetDelta(latest);
|
|
@@ -1081,6 +1081,7 @@ function createProjectionNode({ attachResizeListener, defaultParent, measureScro
|
|
|
1081
1081
|
this.motionValue || (this.motionValue = motionValue(0));
|
|
1082
1082
|
this.currentAnimation = animateSingleValue(this.motionValue, [0, 1000], {
|
|
1083
1083
|
...options,
|
|
1084
|
+
velocity: 0,
|
|
1084
1085
|
isSync: true,
|
|
1085
1086
|
onUpdate: (latest) => {
|
|
1086
1087
|
this.mixTargetDelta(latest);
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { resize } from '../resize/index.mjs';
|
|
2
1
|
import { createScrollInfo } from './info.mjs';
|
|
3
2
|
import { createOnScrollHandler } from './on-scroll-handler.mjs';
|
|
4
3
|
import { noop } from '../../../../../../motion-utils/dist/es/noop.mjs';
|
|
4
|
+
import { resize } from '../../../../../../motion-dom/dist/es/resize/index.mjs';
|
|
5
5
|
import { frame, cancelFrame, frameData } from '../../../../../../motion-dom/dist/es/frameloop/frame.mjs';
|
|
6
6
|
|
|
7
7
|
const scrollListeners = new WeakMap();
|
|
@@ -39,7 +39,10 @@ export { supportsPartialKeyframes } from '../../motion-dom/dist/es/animation/waa
|
|
|
39
39
|
export { supportsBrowserAnimation } from '../../motion-dom/dist/es/animation/waapi/supports/waapi.mjs';
|
|
40
40
|
export { acceleratedValues } from '../../motion-dom/dist/es/animation/waapi/utils/accelerated-values.mjs';
|
|
41
41
|
export { generateLinearEasing } from '../../motion-dom/dist/es/animation/waapi/utils/linear.mjs';
|
|
42
|
+
export { addAttrValue, attrEffect } from '../../motion-dom/dist/es/effects/attr/index.mjs';
|
|
43
|
+
export { propEffect } from '../../motion-dom/dist/es/effects/prop/index.mjs';
|
|
42
44
|
export { addStyleValue, styleEffect } from '../../motion-dom/dist/es/effects/style/index.mjs';
|
|
45
|
+
export { svgEffect } from '../../motion-dom/dist/es/effects/svg/index.mjs';
|
|
43
46
|
export { createRenderBatcher } from '../../motion-dom/dist/es/frameloop/batcher.mjs';
|
|
44
47
|
export { cancelMicrotask, microtask } from '../../motion-dom/dist/es/frameloop/microtask.mjs';
|
|
45
48
|
export { time } from '../../motion-dom/dist/es/frameloop/sync-time.mjs';
|
|
@@ -54,6 +57,7 @@ export { getComputedStyle } from '../../motion-dom/dist/es/render/dom/style-comp
|
|
|
54
57
|
export { setStyle } from '../../motion-dom/dist/es/render/dom/style-set.mjs';
|
|
55
58
|
export { positionalKeys } from '../../motion-dom/dist/es/render/utils/keys-position.mjs';
|
|
56
59
|
export { transformPropOrder, transformProps } from '../../motion-dom/dist/es/render/utils/keys-transform.mjs';
|
|
60
|
+
export { resize } from '../../motion-dom/dist/es/resize/index.mjs';
|
|
57
61
|
export { observeTimeline } from '../../motion-dom/dist/es/scroll/observe.mjs';
|
|
58
62
|
export { recordStats } from '../../motion-dom/dist/es/stats/index.mjs';
|
|
59
63
|
export { activeAnimations } from '../../motion-dom/dist/es/stats/animation-count.mjs';
|
|
@@ -138,7 +138,10 @@ export { supportsPartialKeyframes } from '../../motion-dom/dist/es/animation/waa
|
|
|
138
138
|
export { supportsBrowserAnimation } from '../../motion-dom/dist/es/animation/waapi/supports/waapi.mjs';
|
|
139
139
|
export { acceleratedValues } from '../../motion-dom/dist/es/animation/waapi/utils/accelerated-values.mjs';
|
|
140
140
|
export { generateLinearEasing } from '../../motion-dom/dist/es/animation/waapi/utils/linear.mjs';
|
|
141
|
+
export { addAttrValue, attrEffect } from '../../motion-dom/dist/es/effects/attr/index.mjs';
|
|
142
|
+
export { propEffect } from '../../motion-dom/dist/es/effects/prop/index.mjs';
|
|
141
143
|
export { addStyleValue, styleEffect } from '../../motion-dom/dist/es/effects/style/index.mjs';
|
|
144
|
+
export { svgEffect } from '../../motion-dom/dist/es/effects/svg/index.mjs';
|
|
142
145
|
export { createRenderBatcher } from '../../motion-dom/dist/es/frameloop/batcher.mjs';
|
|
143
146
|
export { cancelMicrotask, microtask } from '../../motion-dom/dist/es/frameloop/microtask.mjs';
|
|
144
147
|
export { time } from '../../motion-dom/dist/es/frameloop/sync-time.mjs';
|
|
@@ -153,6 +156,7 @@ export { getComputedStyle } from '../../motion-dom/dist/es/render/dom/style-comp
|
|
|
153
156
|
export { setStyle } from '../../motion-dom/dist/es/render/dom/style-set.mjs';
|
|
154
157
|
export { positionalKeys } from '../../motion-dom/dist/es/render/utils/keys-position.mjs';
|
|
155
158
|
export { transformPropOrder, transformProps } from '../../motion-dom/dist/es/render/utils/keys-transform.mjs';
|
|
159
|
+
export { resize } from '../../motion-dom/dist/es/resize/index.mjs';
|
|
156
160
|
export { observeTimeline } from '../../motion-dom/dist/es/scroll/observe.mjs';
|
|
157
161
|
export { recordStats } from '../../motion-dom/dist/es/stats/index.mjs';
|
|
158
162
|
export { activeAnimations } from '../../motion-dom/dist/es/stats/animation-count.mjs';
|