@pixodesk/svg-animator-web 1.0.40 → 1.0.41
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/README.md +12 -4
- package/dist/{internal-BmFv1B6H.d.cts → PxAnimator-yjuSFhQw.d.cts} +8 -29
- package/dist/{internal-BmFv1B6H.d.ts → PxAnimator-yjuSFhQw.d.ts} +8 -29
- package/dist/{chunk-TNWZIIVG.js → chunk-BYDBNKO7.js} +1 -1
- package/dist/chunk-BYDBNKO7.js.map +1 -0
- package/dist/index.cjs +227 -230
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +10 -10
- package/dist/index.d.ts +10 -10
- package/dist/index.js +222 -222
- package/dist/index.js.map +1 -1
- package/dist/index.min.cjs +1 -1
- package/dist/index.min.js +1 -1
- package/dist/index.prerendered-waapi.umd.js +53 -53
- package/dist/index.prerendered-waapi.umd.js.map +1 -1
- package/dist/index.prerendered-waapi.umd.min.js +1 -1
- package/dist/index.prerendered.umd.js +68 -68
- package/dist/index.prerendered.umd.js.map +1 -1
- package/dist/index.prerendered.umd.min.js +1 -1
- package/dist/internal.cjs.map +1 -1
- package/dist/internal.d.cts +24 -1
- package/dist/internal.d.ts +24 -1
- package/dist/internal.js +1 -1
- package/dist/internal.min.cjs +1 -1
- package/dist/pixodesk-svg-animator.umd.js +137 -137
- package/dist/pixodesk-svg-animator.umd.js.map +1 -1
- package/dist/pixodesk-svg-animator.umd.min.js +1 -1
- package/package.json +2 -2
- package/dist/chunk-TNWZIIVG.js.map +0 -1
|
@@ -545,7 +545,7 @@ var PixodeskAnimator = (() => {
|
|
|
545
545
|
* The base can be the result of px.object() or px.openObject() — anything with a _shape property.
|
|
546
546
|
*
|
|
547
547
|
* @example
|
|
548
|
-
* const PxSvgNodeSchema = px.extendedObject(
|
|
548
|
+
* const PxSvgNodeSchema = px.extendedObject(PxNodeBaseSchema, { width: px.number().optional() });
|
|
549
549
|
*/
|
|
550
550
|
extendedObject: (base, extra) => new Obj(__spreadValues(__spreadValues({}, base._shape), extra)),
|
|
551
551
|
/** Array whose unrecoverable items are filtered out. Default: []. */
|
|
@@ -637,14 +637,14 @@ var PixodeskAnimator = (() => {
|
|
|
637
637
|
native: "native",
|
|
638
638
|
js: "js"
|
|
639
639
|
};
|
|
640
|
-
var
|
|
640
|
+
var PxTimelineEngineSetting = __spreadProps(__spreadValues({}, PxTimelineEngine), {
|
|
641
641
|
auto: "auto"
|
|
642
642
|
});
|
|
643
643
|
function isNativeForced(engine) {
|
|
644
|
-
return engine ===
|
|
644
|
+
return engine === PxTimelineEngineSetting.native;
|
|
645
645
|
}
|
|
646
646
|
function mayUseNativeScrollTimeline(engine) {
|
|
647
|
-
return engine !==
|
|
647
|
+
return engine !== PxTimelineEngineSetting.js;
|
|
648
648
|
}
|
|
649
649
|
var PX_TRIGGER_DEFAULTS = {
|
|
650
650
|
startOn: "load",
|
|
@@ -786,7 +786,7 @@ var PixodeskAnimator = (() => {
|
|
|
786
786
|
flattenMemo.set(cfg, flat);
|
|
787
787
|
return flat;
|
|
788
788
|
}
|
|
789
|
-
function
|
|
789
|
+
function getDefinitions(doc) {
|
|
790
790
|
var _a;
|
|
791
791
|
if (!doc) return void 0;
|
|
792
792
|
return (_a = getAnimatorConfig(doc)) == null ? void 0 : _a.definitions;
|
|
@@ -829,20 +829,20 @@ var PixodeskAnimator = (() => {
|
|
|
829
829
|
// its internal COPY-PASTE payload, which never validates against this schema.)
|
|
830
830
|
}));
|
|
831
831
|
var anyKf = (kf) => kf;
|
|
832
|
-
var
|
|
832
|
+
var keyframeTime = (kf) => {
|
|
833
833
|
var _a, _b;
|
|
834
834
|
return (_b = (_a = anyKf(kf).time) != null ? _a : anyKf(kf).t) != null ? _b : 0;
|
|
835
835
|
};
|
|
836
|
-
var
|
|
836
|
+
var keyframeValue = (kf) => {
|
|
837
837
|
var _a;
|
|
838
838
|
return (_a = anyKf(kf).value) != null ? _a : anyKf(kf).v;
|
|
839
839
|
};
|
|
840
|
-
var
|
|
840
|
+
var keyframeEasing = (kf) => {
|
|
841
841
|
var _a;
|
|
842
842
|
return (_a = anyKf(kf).easing) != null ? _a : anyKf(kf).e;
|
|
843
843
|
};
|
|
844
|
-
var
|
|
845
|
-
var
|
|
844
|
+
var keyframeTangentIn = (kf) => anyKf(kf).tangentIn;
|
|
845
|
+
var keyframeTangentOut = (kf) => anyKf(kf).tangentOut;
|
|
846
846
|
var PxLoopSchema = implementsInterface()(px.object({
|
|
847
847
|
segmentCount: px.number().optional(),
|
|
848
848
|
repeatAt: px.enum([PxLoopRepeatAt.start, PxLoopRepeatAt.end]).optional(),
|
|
@@ -896,7 +896,7 @@ var PixodeskAnimator = (() => {
|
|
|
896
896
|
unitsPerEm: px.number(),
|
|
897
897
|
glyphs: px.record(PxGlyphSchema)
|
|
898
898
|
}));
|
|
899
|
-
var
|
|
899
|
+
var PxDefinitionsSchema = implementsInterface()(px.object({
|
|
900
900
|
easings: px.record(px.tuple([px.number(), px.number(), px.number(), px.number()])).optional(),
|
|
901
901
|
animations: px.record(PxAnimationDefinitionSchema).optional(),
|
|
902
902
|
fonts: px.record(PxGlyphFontSchema).optional()
|
|
@@ -934,7 +934,7 @@ var PixodeskAnimator = (() => {
|
|
|
934
934
|
offset: px.number().optional(),
|
|
935
935
|
distance: px.number().optional()
|
|
936
936
|
}));
|
|
937
|
-
var PxTimelineEngineSchema = px.enum([
|
|
937
|
+
var PxTimelineEngineSchema = px.enum([PxTimelineEngineSetting.auto, PxTimelineEngineSetting.native, PxTimelineEngineSetting.js]).optional();
|
|
938
938
|
var PxTimeTimelineSchema = implementsInterface()(px.object({
|
|
939
939
|
type: px.literal("time").optional(),
|
|
940
940
|
engine: PxTimelineEngineSchema,
|
|
@@ -988,7 +988,7 @@ var PixodeskAnimator = (() => {
|
|
|
988
988
|
// at this level only on the runtime view, like the rest of the playback dynamics.)
|
|
989
989
|
// THE spelling of "what advances progress" — clock / scroll / view (review §2.1).
|
|
990
990
|
timeline: PxTimelineSchema.optional(),
|
|
991
|
-
definitions:
|
|
991
|
+
definitions: PxDefinitionsSchema.optional(),
|
|
992
992
|
bindings: px.array(PxBindingSchema).optional(),
|
|
993
993
|
debugGlobalName: px.string().optional(),
|
|
994
994
|
// Declared HERE because this is a closed object: an undeclared key would be stripped by
|
|
@@ -1077,7 +1077,7 @@ var PixodeskAnimator = (() => {
|
|
|
1077
1077
|
PxPropertyAnimationSchema
|
|
1078
1078
|
]);
|
|
1079
1079
|
var PxFillGradientEffectSchema = implementsInterface()(px.object({
|
|
1080
|
-
// Contextual kind — the `type` convention, see `
|
|
1080
|
+
// Contextual kind — the `type` convention, see `PxNodeBaseSchema.type`.
|
|
1081
1081
|
type: px.enum([PxGradientType.linear, PxGradientType.radial]),
|
|
1082
1082
|
start: PxAnimatableVec2Schema.optional(),
|
|
1083
1083
|
end: PxAnimatableVec2Schema.optional(),
|
|
@@ -1114,7 +1114,7 @@ var PixodeskAnimator = (() => {
|
|
|
1114
1114
|
textPath: PxTextPathEffectSchema.optional(),
|
|
1115
1115
|
text: PxTextEffectSchema.optional()
|
|
1116
1116
|
}));
|
|
1117
|
-
var
|
|
1117
|
+
var PxNodeBaseSchema = px.openObject({
|
|
1118
1118
|
// CONVENTION (SCHEMA-DESIGN R1 / issues N4): `type` is the ONE word for "what
|
|
1119
1119
|
// kind of thing is this", discriminated by its CARRIER — here the node TAG
|
|
1120
1120
|
// (`rect`, `text`), and inside a sub-object that object's kind (`fillGradient.type`,
|
|
@@ -1129,7 +1129,7 @@ var PixodeskAnimator = (() => {
|
|
|
1129
1129
|
// `type` is taken by the tag name, so the attribute travels here and the renderer puts
|
|
1130
1130
|
// it back (`PxAnimatorDOM.renderNode`, `PxRnRender`). Declared here — not merely
|
|
1131
1131
|
// documented — because a wire key that is not in a schema is invisible to the
|
|
1132
|
-
// minifier's reserve list and gets renamed (
|
|
1132
|
+
// minifier's reserve list and gets renamed (dev-docs/plans/minification-boundary.md §1.1).
|
|
1133
1133
|
domType: px.string().optional(),
|
|
1134
1134
|
// Text content of a `<text>` / `<tspan>`. Declared, so a non-string value is a schema error
|
|
1135
1135
|
// and the minifier reserves the key; `text` is NOT an alias for it and is not read anywhere.
|
|
@@ -1137,7 +1137,7 @@ var PixodeskAnimator = (() => {
|
|
|
1137
1137
|
id: px.string().optional(),
|
|
1138
1138
|
meta: px.any().optional(),
|
|
1139
1139
|
// Player-effects bucket emitted by the Editor's lightweight design format.
|
|
1140
|
-
// Consumed and removed by `
|
|
1140
|
+
// Consumed and removed by `materializeNodeEffects` before any other normalization
|
|
1141
1141
|
// (see `createAnimatorImpl`), so downstream code never sees it.
|
|
1142
1142
|
effects: PxEffectsSchema.optional(),
|
|
1143
1143
|
// `PxElementAnimation` (not just `PxAnimationDefinition`) — accepts
|
|
@@ -1146,10 +1146,10 @@ var PixodeskAnimator = (() => {
|
|
|
1146
1146
|
animate: PxElementAnimationSchema.optional(),
|
|
1147
1147
|
style: px.record(px.union([px.string(), px.number()])).optional()
|
|
1148
1148
|
}, PxAttrValueSchema);
|
|
1149
|
-
var PxNodeSchema = px.openObject(__spreadProps(__spreadValues({},
|
|
1149
|
+
var PxNodeSchema = px.openObject(__spreadProps(__spreadValues({}, PxNodeBaseSchema._shape), {
|
|
1150
1150
|
children: px.lazy(() => px.array(PxNodeSchema), []).optional()
|
|
1151
1151
|
}), PxAttrValueSchema);
|
|
1152
|
-
var
|
|
1152
|
+
var PxSvgNodeRootSchema = px.object({
|
|
1153
1153
|
// `"100%"` and other SVG length strings are legal here — a number-only slot rejected
|
|
1154
1154
|
// real documents (e.g. apple-store-look-14-main.json) at the root <svg>.
|
|
1155
1155
|
width: px.union([px.number(), px.string()]).optional(),
|
|
@@ -1157,7 +1157,7 @@ var PixodeskAnimator = (() => {
|
|
|
1157
1157
|
viewBox: px.string().optional(),
|
|
1158
1158
|
animator: PxAnimatorConfigSchema.optional()
|
|
1159
1159
|
});
|
|
1160
|
-
var PxAnimatedSvgDocumentSchema = px.openObject(__spreadProps(__spreadValues(__spreadValues({},
|
|
1160
|
+
var PxAnimatedSvgDocumentSchema = px.openObject(__spreadProps(__spreadValues(__spreadValues({}, PxNodeBaseSchema._shape), PxSvgNodeRootSchema._shape), {
|
|
1161
1161
|
type: px.literal("svg"),
|
|
1162
1162
|
// override string → literal to require 'svg'
|
|
1163
1163
|
children: px.array(PxNodeSchema).optional()
|
|
@@ -1399,9 +1399,9 @@ var PixodeskAnimator = (() => {
|
|
|
1399
1399
|
}
|
|
1400
1400
|
return void 0;
|
|
1401
1401
|
}
|
|
1402
|
-
var
|
|
1403
|
-
var
|
|
1404
|
-
var
|
|
1402
|
+
var PX_COLOR_ATTR_NAMES = /* @__PURE__ */ new Set(["color", "fill", "flood-color", "lighting-color", "stop-color", "stroke"]);
|
|
1403
|
+
var PX_TRANSFORM_FN_NAMES = /* @__PURE__ */ new Set(["translate", "rotate", "scale", "skew"]);
|
|
1404
|
+
var PX_PCT_BASED_ATTR_NAMES = /* @__PURE__ */ new Set(["offset-distance", "offsetDistance"]);
|
|
1405
1405
|
function composeTransformParts(parts, opts) {
|
|
1406
1406
|
var _a;
|
|
1407
1407
|
if (!parts) return "";
|
|
@@ -1454,8 +1454,8 @@ var PixodeskAnimator = (() => {
|
|
|
1454
1454
|
if (str.replace(/([a-zA-Z]+)\s*\(([^)]*)\)/g, "").replace(/[\s,]/g, "").length) return void 0;
|
|
1455
1455
|
return Object.keys(out).length ? out : void 0;
|
|
1456
1456
|
}
|
|
1457
|
-
var
|
|
1458
|
-
var
|
|
1457
|
+
var PX_STYLE_ATTR_NAMES = /* @__PURE__ */ new Set(["offset-distance", "offsetDistance"]);
|
|
1458
|
+
var PX_DEFAULT_DURATION_MS = 1e3;
|
|
1459
1459
|
function kebabToCamelCaseWord(kebab) {
|
|
1460
1460
|
return kebab.includes("-") ? kebab.replace(/-([a-z])/g, (_, letter) => letter.toUpperCase()) : kebab;
|
|
1461
1461
|
}
|
|
@@ -1601,7 +1601,7 @@ var PixodeskAnimator = (() => {
|
|
|
1601
1601
|
|
|
1602
1602
|
// ../svg-animator-core/src/materialize/PxMotionPath.ts
|
|
1603
1603
|
function getKfTranslate(kf) {
|
|
1604
|
-
const v =
|
|
1604
|
+
const v = keyframeValue(kf);
|
|
1605
1605
|
if (!v) return void 0;
|
|
1606
1606
|
if (Array.isArray(v) && v.length >= 2 && typeof v[0] === "number" && typeof v[1] === "number") {
|
|
1607
1607
|
return [v[0], v[1]];
|
|
@@ -1611,17 +1611,17 @@ var PixodeskAnimator = (() => {
|
|
|
1611
1611
|
return void 0;
|
|
1612
1612
|
}
|
|
1613
1613
|
function getKfTime(kf) {
|
|
1614
|
-
return
|
|
1614
|
+
return keyframeTime(kf);
|
|
1615
1615
|
}
|
|
1616
1616
|
function getKfEasing(kf) {
|
|
1617
|
-
return
|
|
1617
|
+
return keyframeEasing(kf);
|
|
1618
1618
|
}
|
|
1619
1619
|
function propAnimIsMotionPath(anim) {
|
|
1620
1620
|
const kfs = anim.keyframes;
|
|
1621
1621
|
if (!Array.isArray(kfs)) return false;
|
|
1622
1622
|
if (anim.autoOrient) return true;
|
|
1623
1623
|
for (const kf of kfs) {
|
|
1624
|
-
if (
|
|
1624
|
+
if (keyframeTangentIn(kf) || keyframeTangentOut(kf)) return true;
|
|
1625
1625
|
}
|
|
1626
1626
|
return false;
|
|
1627
1627
|
}
|
|
@@ -1630,8 +1630,8 @@ var PixodeskAnimator = (() => {
|
|
|
1630
1630
|
let byNext = _segmentCache.get(prevKf);
|
|
1631
1631
|
const existing = byNext == null ? void 0 : byNext.get(nextKf);
|
|
1632
1632
|
if (existing) return existing;
|
|
1633
|
-
const to =
|
|
1634
|
-
const ti =
|
|
1633
|
+
const to = keyframeTangentOut(prevKf);
|
|
1634
|
+
const ti = keyframeTangentIn(nextKf);
|
|
1635
1635
|
const P1 = [prevPos[0] + (to ? to[0] : 0), prevPos[1] + (to ? to[1] : 0)];
|
|
1636
1636
|
const P2 = [nextPos[0] + (ti ? ti[0] : 0), nextPos[1] + (ti ? ti[1] : 0)];
|
|
1637
1637
|
const lut = bezier2D_arcLengthLUT(prevPos, P1, P2, nextPos);
|
|
@@ -1724,7 +1724,7 @@ var PixodeskAnimator = (() => {
|
|
|
1724
1724
|
function unwrapAutoOrientRotations(kfs) {
|
|
1725
1725
|
let prev;
|
|
1726
1726
|
for (const kf of kfs) {
|
|
1727
|
-
const v =
|
|
1727
|
+
const v = keyframeValue(kf);
|
|
1728
1728
|
if (!v || typeof v.rotate !== "number") continue;
|
|
1729
1729
|
if (prev === void 0) {
|
|
1730
1730
|
prev = v.rotate;
|
|
@@ -1741,7 +1741,7 @@ var PixodeskAnimator = (() => {
|
|
|
1741
1741
|
return { t: time, v: value };
|
|
1742
1742
|
}
|
|
1743
1743
|
function getKfValueParts(kf) {
|
|
1744
|
-
const v =
|
|
1744
|
+
const v = keyframeValue(kf);
|
|
1745
1745
|
if (!v || typeof v !== "object" || Array.isArray(v)) return void 0;
|
|
1746
1746
|
return v;
|
|
1747
1747
|
}
|
|
@@ -1803,7 +1803,7 @@ var PixodeskAnimator = (() => {
|
|
|
1803
1803
|
}
|
|
1804
1804
|
function insertSharpCornerStepKfIfNeeded(out, prevKf, nextKf, prevPos, nextPos, rotationTol) {
|
|
1805
1805
|
const lastKf = out[out.length - 1];
|
|
1806
|
-
const lastV =
|
|
1806
|
+
const lastV = keyframeValue(lastKf);
|
|
1807
1807
|
const prevExit = lastV == null ? void 0 : lastV.rotate;
|
|
1808
1808
|
if (typeof prevExit !== "number") return;
|
|
1809
1809
|
const boundaryV = getKfValueParts(prevKf);
|
|
@@ -1951,7 +1951,7 @@ var PixodeskAnimator = (() => {
|
|
|
1951
1951
|
}
|
|
1952
1952
|
|
|
1953
1953
|
// ../svg-animator-core/src/animation/PxDefinitions.ts
|
|
1954
|
-
var
|
|
1954
|
+
var PX_LOOP_JUMP_SHIFT_MS = 1;
|
|
1955
1955
|
function deepEqualValue(a, b) {
|
|
1956
1956
|
if (a === b) return true;
|
|
1957
1957
|
if (typeof a !== typeof b || a === null || b === null || typeof a !== "object") return false;
|
|
@@ -2127,7 +2127,7 @@ var PixodeskAnimator = (() => {
|
|
|
2127
2127
|
const bPaths = (_b = b == null ? void 0 : b.paths) != null ? _b : Array.isArray(b) ? b : [];
|
|
2128
2128
|
return { paths: interpolateBeziers(aPaths, bPaths, t) };
|
|
2129
2129
|
}
|
|
2130
|
-
if (
|
|
2130
|
+
if (PX_COLOR_ATTR_NAMES.has(propName)) {
|
|
2131
2131
|
return interpolateColor(a || [0, 0, 0, 1], b || [0, 0, 0, 1], t);
|
|
2132
2132
|
}
|
|
2133
2133
|
if (propName === "transform" && typeof a === "object" && a !== null && !Array.isArray(a) && typeof b === "object" && b !== null && !Array.isArray(b)) {
|
|
@@ -2136,7 +2136,7 @@ var PixodeskAnimator = (() => {
|
|
|
2136
2136
|
if (propName === "rotate" && typeof a === "number" && typeof b === "number") {
|
|
2137
2137
|
return interpolateNum(a, b, t);
|
|
2138
2138
|
}
|
|
2139
|
-
if (
|
|
2139
|
+
if (PX_TRANSFORM_FN_NAMES.has(propName) || propName === "stroke-dasharray" || propName === "strokeDasharray") {
|
|
2140
2140
|
return interpolateVec(a || [], b || [], t);
|
|
2141
2141
|
}
|
|
2142
2142
|
return interpolateNum(+(a || 0), +(b || 0), t);
|
|
@@ -2188,8 +2188,8 @@ var PixodeskAnimator = (() => {
|
|
|
2188
2188
|
relT: (kf.t - segStartT) / segDuration,
|
|
2189
2189
|
v: kf.v,
|
|
2190
2190
|
e: kf.e,
|
|
2191
|
-
tangentIn:
|
|
2192
|
-
tangentOut:
|
|
2191
|
+
tangentIn: keyframeTangentIn(kf),
|
|
2192
|
+
tangentOut: keyframeTangentOut(kf)
|
|
2193
2193
|
}));
|
|
2194
2194
|
const fullReps = Math.floor(fillDuration / segDuration);
|
|
2195
2195
|
const remainder = fillDuration - fullReps * segDuration;
|
|
@@ -2255,7 +2255,7 @@ var PixodeskAnimator = (() => {
|
|
|
2255
2255
|
}
|
|
2256
2256
|
}
|
|
2257
2257
|
const pushed = {
|
|
2258
|
-
t: repStart + entry.relT * segDuration + (isBoundary ?
|
|
2258
|
+
t: repStart + entry.relT * segDuration + (isBoundary ? PX_LOOP_JUMP_SHIFT_MS : 0),
|
|
2259
2259
|
v: entry.v,
|
|
2260
2260
|
e: i < entries.length - 1 ? entry.e : void 0
|
|
2261
2261
|
};
|
|
@@ -2342,14 +2342,14 @@ var PixodeskAnimator = (() => {
|
|
|
2342
2342
|
const keyframes = propAnim.keyframes || [];
|
|
2343
2343
|
const normalized = [];
|
|
2344
2344
|
for (const kf of keyframes) {
|
|
2345
|
-
const timePct =
|
|
2346
|
-
let value =
|
|
2347
|
-
const easing =
|
|
2345
|
+
const timePct = keyframeTime(kf);
|
|
2346
|
+
let value = keyframeValue(kf);
|
|
2347
|
+
const easing = keyframeEasing(kf);
|
|
2348
2348
|
if (propName === "d") {
|
|
2349
2349
|
value = normalizePathValue(value);
|
|
2350
2350
|
}
|
|
2351
2351
|
const propNameKebab = isCamelCaseWord(propName) ? camelCaseToKebabWordIfNeeded(propName) : propName;
|
|
2352
|
-
if (
|
|
2352
|
+
if (PX_COLOR_ATTR_NAMES.has(propNameKebab)) {
|
|
2353
2353
|
value = (_a = parseColor(value)) != null ? _a : value;
|
|
2354
2354
|
}
|
|
2355
2355
|
const normKf = {
|
|
@@ -2357,8 +2357,8 @@ var PixodeskAnimator = (() => {
|
|
|
2357
2357
|
v: value,
|
|
2358
2358
|
e: resolveEasing(easing, defs)
|
|
2359
2359
|
};
|
|
2360
|
-
const tIn =
|
|
2361
|
-
const tOut =
|
|
2360
|
+
const tIn = keyframeTangentIn(kf);
|
|
2361
|
+
const tOut = keyframeTangentOut(kf);
|
|
2362
2362
|
if (tIn) normKf.tangentIn = tIn;
|
|
2363
2363
|
if (tOut) normKf.tangentOut = tOut;
|
|
2364
2364
|
normalized.push(normKf);
|
|
@@ -2404,7 +2404,7 @@ var PixodeskAnimator = (() => {
|
|
|
2404
2404
|
}
|
|
2405
2405
|
return animDef;
|
|
2406
2406
|
}
|
|
2407
|
-
const channels = Object.keys(animDef).filter((k) =>
|
|
2407
|
+
const channels = Object.keys(animDef).filter((k) => PX_TRANSFORM_FN_NAMES.has(k));
|
|
2408
2408
|
if (channels.length !== 1) return animDef;
|
|
2409
2409
|
const ch = channels[0];
|
|
2410
2410
|
const chAnim = animDef[ch];
|
|
@@ -2433,9 +2433,9 @@ var PixodeskAnimator = (() => {
|
|
|
2433
2433
|
}
|
|
2434
2434
|
return normalized;
|
|
2435
2435
|
}
|
|
2436
|
-
function
|
|
2436
|
+
function normalizeBindings(doc, engine = PxTimelineEngine.native) {
|
|
2437
2437
|
const animatorConfig = getAnimatorConfig(doc) || {};
|
|
2438
|
-
const defs =
|
|
2438
|
+
const defs = getDefinitions(doc);
|
|
2439
2439
|
const duration = animatorConfig.duration || 1e3;
|
|
2440
2440
|
const bindings = [];
|
|
2441
2441
|
const processAnimation = (id, animDefs, staticTransform) => {
|
|
@@ -2505,7 +2505,7 @@ var PixodeskAnimator = (() => {
|
|
|
2505
2505
|
const { prevKf, nextKf } = getKeyframesPair(keyframes, progress);
|
|
2506
2506
|
let localProgress = prevKf === nextKf ? 0 : remap(progress, (_a = prevKf.t) != null ? _a : 0, (_b = nextKf.t) != null ? _b : 0, 0, 1);
|
|
2507
2507
|
localProgress = clamp(localProgress, 0, 1);
|
|
2508
|
-
const easing =
|
|
2508
|
+
const easing = keyframeEasing(prevKf);
|
|
2509
2509
|
if (easing && Array.isArray(easing)) {
|
|
2510
2510
|
try {
|
|
2511
2511
|
localProgress = cubicBezier(easing)(localProgress);
|
|
@@ -2524,7 +2524,7 @@ var PixodeskAnimator = (() => {
|
|
|
2524
2524
|
nextPaths,
|
|
2525
2525
|
localProgress
|
|
2526
2526
|
).map((bz) => bezierToSvgPath(bz)).join("");
|
|
2527
|
-
} else if (
|
|
2527
|
+
} else if (PX_COLOR_ATTR_NAMES.has(cssAttrName)) {
|
|
2528
2528
|
cssValue = toRGBA(interpolateColor(
|
|
2529
2529
|
prevV || [0, 0, 0, 1],
|
|
2530
2530
|
nextV || [0, 0, 0, 1],
|
|
@@ -2605,7 +2605,7 @@ var PixodeskAnimator = (() => {
|
|
|
2605
2605
|
);
|
|
2606
2606
|
cssValue = num;
|
|
2607
2607
|
}
|
|
2608
|
-
if (
|
|
2608
|
+
if (PX_PCT_BASED_ATTR_NAMES.has(cssAttrName) && typeof cssValue === "number") {
|
|
2609
2609
|
cssValue = cssValue * 100 + "%";
|
|
2610
2610
|
}
|
|
2611
2611
|
return { k: cssAttrName, v: cssValue === null ? "" : "" + cssValue };
|
|
@@ -2669,16 +2669,16 @@ var PixodeskAnimator = (() => {
|
|
|
2669
2669
|
}
|
|
2670
2670
|
g.clearTimeout(handle);
|
|
2671
2671
|
}
|
|
2672
|
-
function
|
|
2672
|
+
function createAdapterAnimator(doc, adapter, callbacks) {
|
|
2673
2673
|
var _a;
|
|
2674
2674
|
const config = getAnimatorConfig(doc) || {};
|
|
2675
|
-
const bindings =
|
|
2675
|
+
const bindings = normalizeBindings(doc, PxTimelineEngine.js);
|
|
2676
2676
|
const _iterations = config.iterations;
|
|
2677
2677
|
let iterations = 1;
|
|
2678
2678
|
if (typeof _iterations === "number") iterations = _iterations || 1;
|
|
2679
2679
|
if (_iterations === "infinite") iterations = Infinity;
|
|
2680
2680
|
if (iterations < 1) iterations = 1;
|
|
2681
|
-
const duration = +(config.duration ||
|
|
2681
|
+
const duration = +(config.duration || PX_DEFAULT_DURATION_MS);
|
|
2682
2682
|
const totalDuration = duration && iterations ? duration * (iterations === Infinity ? Infinity : iterations) : duration ? (iterations != null ? iterations : 1) * duration : 0;
|
|
2683
2683
|
const direction = config.direction || "normal";
|
|
2684
2684
|
const fill = (_a = config.fill) != null ? _a : "forwards";
|
|
@@ -2984,7 +2984,7 @@ var PixodeskAnimator = (() => {
|
|
|
2984
2984
|
return (config == null ? void 0 : config.timelineSource) === "scroll";
|
|
2985
2985
|
}
|
|
2986
2986
|
function scrollTotalDurationMs(config) {
|
|
2987
|
-
const duration = typeof (config == null ? void 0 : config.duration) === "number" && config.duration > 0 ? config.duration :
|
|
2987
|
+
const duration = typeof (config == null ? void 0 : config.duration) === "number" && config.duration > 0 ? config.duration : PX_DEFAULT_DURATION_MS;
|
|
2988
2988
|
const iterations = typeof (config == null ? void 0 : config.iterations) === "number" && config.iterations > 0 ? config.iterations : 1;
|
|
2989
2989
|
return duration * iterations;
|
|
2990
2990
|
}
|
|
@@ -3084,13 +3084,13 @@ var PixodeskAnimator = (() => {
|
|
|
3084
3084
|
}
|
|
3085
3085
|
|
|
3086
3086
|
// src/triggers/PxAnimatorTriggers.ts
|
|
3087
|
-
function setupAnimationTriggers(api,
|
|
3087
|
+
function setupAnimationTriggers(api, trigger, diag) {
|
|
3088
3088
|
const report = diag != null ? diag : createDiagnostics(void 0, "[PxAnimator]");
|
|
3089
3089
|
const cleanups = [];
|
|
3090
3090
|
const dispose = () => {
|
|
3091
3091
|
for (const undo of cleanups.splice(0)) undo();
|
|
3092
3092
|
};
|
|
3093
|
-
const { startOn, outAction, scrollIntoViewThreshold } = resolveTrigger(
|
|
3093
|
+
const { startOn, outAction, scrollIntoViewThreshold } = resolveTrigger(trigger);
|
|
3094
3094
|
const root = api.getRootElement();
|
|
3095
3095
|
if (!root) {
|
|
3096
3096
|
report.warn(PxDiagnosticKind.host, "setupAnimationTriggers: No root element found for animation.");
|
|
@@ -3217,7 +3217,7 @@ var PixodeskAnimator = (() => {
|
|
|
3217
3217
|
diag.warn(PxDiagnosticKind.host, "createFrameLoopAnimator: No root element provided");
|
|
3218
3218
|
}
|
|
3219
3219
|
}
|
|
3220
|
-
const basicApi =
|
|
3220
|
+
const basicApi = createAdapterAnimator(
|
|
3221
3221
|
doc,
|
|
3222
3222
|
adapter || createDomAdapter(rootElement, diag),
|
|
3223
3223
|
callbacks
|
|
@@ -3257,7 +3257,7 @@ var PixodeskAnimator = (() => {
|
|
|
3257
3257
|
const element = elements[i];
|
|
3258
3258
|
const effectiveAttrName = attrName === "transform" && element.tagName === "pattern" ? "patternTransform" : attrName;
|
|
3259
3259
|
element.setAttribute(effectiveAttrName, value);
|
|
3260
|
-
if (
|
|
3260
|
+
if (PX_STYLE_ATTR_NAMES.has(attrName)) {
|
|
3261
3261
|
element.style[attrName] = value;
|
|
3262
3262
|
}
|
|
3263
3263
|
}
|
|
@@ -3268,20 +3268,20 @@ var PixodeskAnimator = (() => {
|
|
|
3268
3268
|
|
|
3269
3269
|
// src/engines/PxAnimatorWebApi.ts
|
|
3270
3270
|
function createCssKf(kf, t, propName, unsupportedSet) {
|
|
3271
|
-
let value =
|
|
3272
|
-
const e =
|
|
3271
|
+
let value = keyframeValue(kf);
|
|
3272
|
+
const e = keyframeEasing(kf);
|
|
3273
3273
|
const cssKf = {
|
|
3274
3274
|
offset: t,
|
|
3275
3275
|
easing: e && Array.isArray(e) ? "cubic-bezier(" + e.join(",") + ")" : void 0
|
|
3276
3276
|
};
|
|
3277
3277
|
let cssValue;
|
|
3278
3278
|
let cssKey = propName;
|
|
3279
|
-
if (
|
|
3279
|
+
if (PX_COLOR_ATTR_NAMES.has(propName) && Array.isArray(value)) {
|
|
3280
3280
|
cssValue = toRGBA(value);
|
|
3281
3281
|
} else if (propName === "transform" && value !== null && typeof value === "object" && !Array.isArray(value)) {
|
|
3282
3282
|
cssValue = composeTransformParts(value, { withUnits: true });
|
|
3283
3283
|
cssKey = "transform";
|
|
3284
|
-
} else if (
|
|
3284
|
+
} else if (PX_TRANSFORM_FN_NAMES.has(propName)) {
|
|
3285
3285
|
if (Array.isArray(value)) {
|
|
3286
3286
|
if (propName === "translate") value = value.map((v) => v + "px");
|
|
3287
3287
|
value = value.join(",");
|
|
@@ -3292,7 +3292,7 @@ var PixodeskAnimator = (() => {
|
|
|
3292
3292
|
} else if (propName === "d") {
|
|
3293
3293
|
const paths = value && typeof value === "object" && Array.isArray(value.paths) ? value.paths : [];
|
|
3294
3294
|
cssValue = 'path("' + paths.map((bz) => bezierToSvgPath(bz, true)).join("") + '")';
|
|
3295
|
-
} else if (
|
|
3295
|
+
} else if (PX_PCT_BASED_ATTR_NAMES.has(propName) && typeof value === "number") {
|
|
3296
3296
|
cssValue = value * 100 + "%";
|
|
3297
3297
|
} else {
|
|
3298
3298
|
cssValue = "" + value;
|
|
@@ -3375,7 +3375,7 @@ var PixodeskAnimator = (() => {
|
|
|
3375
3375
|
diag.warn(PxDiagnosticKind.host, "createWebApiAnimator: No root element provided");
|
|
3376
3376
|
}
|
|
3377
3377
|
}
|
|
3378
|
-
const bindings =
|
|
3378
|
+
const bindings = normalizeBindings(doc, PxTimelineEngine.native);
|
|
3379
3379
|
const animations = [];
|
|
3380
3380
|
const _iterations = config.iterations;
|
|
3381
3381
|
let iterations;
|
|
@@ -3857,7 +3857,7 @@ var PixodeskAnimator = (() => {
|
|
|
3857
3857
|
unpin = () => {
|
|
3858
3858
|
};
|
|
3859
3859
|
}
|
|
3860
|
-
const api = (animatorConfig.engine !==
|
|
3860
|
+
const api = (animatorConfig.engine !== PxTimelineEngineSetting.js ? createWebApiAnimator(doc, cb, rootElement, isNativeForced(animatorConfig.engine)) : null) || createFrameLoopAnimator(doc, adapter, cb, rootElement);
|
|
3861
3861
|
const subject = ((_a = api.getRootElement) == null ? void 0 : _a.call(api)) || rootElement;
|
|
3862
3862
|
if (subject) {
|
|
3863
3863
|
unpin = applyScrollPin(subject, animatorConfig.scroll);
|
|
@@ -3883,7 +3883,7 @@ var PixodeskAnimator = (() => {
|
|
|
3883
3883
|
});
|
|
3884
3884
|
}
|
|
3885
3885
|
return finaliseAnimator(animatorConfig, callbacks, (cb) => {
|
|
3886
|
-
if (animatorConfig.engine ===
|
|
3886
|
+
if (animatorConfig.engine === PxTimelineEngineSetting.js) {
|
|
3887
3887
|
return createFrameLoopAnimator(doc, adapter, cb, rootElement);
|
|
3888
3888
|
}
|
|
3889
3889
|
return createWebApiAnimator(
|