@pixodesk/svg-animator-web 1.0.24 → 1.0.27
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/index.cjs +1062 -665
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +8 -1
- package/dist/index.d.ts +8 -1
- package/dist/index.js +1062 -665
- 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 +74 -40
- 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 +292 -41
- package/dist/index.prerendered.umd.js.map +1 -1
- package/dist/index.prerendered.umd.min.js +1 -1
- package/dist/index.umd.js +1070 -669
- package/dist/index.umd.js.map +1 -1
- package/dist/index.umd.min.js +1 -1
- package/package.json +2 -2
|
@@ -43,41 +43,6 @@ var PixodeskAnimator = (() => {
|
|
|
43
43
|
setupAnimationTriggers: () => setupAnimationTriggers
|
|
44
44
|
});
|
|
45
45
|
|
|
46
|
-
// ../svg-animator-core/src/PxAnimatorConstants.ts
|
|
47
|
-
var PxAnimatorMode = {
|
|
48
|
-
auto: "auto",
|
|
49
|
-
waapi: "waapi",
|
|
50
|
-
frames: "frames"
|
|
51
|
-
};
|
|
52
|
-
var PxAnimatorEngine = {
|
|
53
|
-
waapi: PxAnimatorMode.waapi,
|
|
54
|
-
frames: PxAnimatorMode.frames
|
|
55
|
-
};
|
|
56
|
-
var PxLoopExtend = {
|
|
57
|
-
/** Segment from the START; the animation is extended BEFORE the first keyframe
|
|
58
|
-
* (intro loops that run before the main timeline begins). */
|
|
59
|
-
before: "before",
|
|
60
|
-
/** DEFAULT — segment from the END; extended AFTER the last keyframe (idle/outro
|
|
61
|
-
* loops that continue once the main timeline has finished). */
|
|
62
|
-
after: "after"
|
|
63
|
-
};
|
|
64
|
-
function getAnimatorConfig(doc) {
|
|
65
|
-
var _a;
|
|
66
|
-
return (doc == null ? void 0 : doc.animator) || ((_a = doc == null ? void 0 : doc.meta) == null ? void 0 : _a.animator);
|
|
67
|
-
}
|
|
68
|
-
function getDefs(doc) {
|
|
69
|
-
var _a;
|
|
70
|
-
if (!doc) return void 0;
|
|
71
|
-
return (_a = getAnimatorConfig(doc)) == null ? void 0 : _a.definitions;
|
|
72
|
-
}
|
|
73
|
-
function getBindings(doc) {
|
|
74
|
-
var _a;
|
|
75
|
-
if (!doc) return void 0;
|
|
76
|
-
const animateById = (_a = getAnimatorConfig(doc)) == null ? void 0 : _a.animateById;
|
|
77
|
-
if (!animateById) return void 0;
|
|
78
|
-
return Object.entries(animateById).map(([id, anim]) => ({ id, animate: anim }));
|
|
79
|
-
}
|
|
80
|
-
|
|
81
46
|
// ../svg-animator-core/src/PxAnimatorUtil.ts
|
|
82
47
|
function bezierToSvgPath(path, forceCurves = false) {
|
|
83
48
|
var _a, _b, _c, _d;
|
|
@@ -305,6 +270,7 @@ var PixodeskAnimator = (() => {
|
|
|
305
270
|
}
|
|
306
271
|
var COLOUR_ATTR_NAMES = /* @__PURE__ */ new Set(["color", "fill", "flood-color", "lighting-color", "stop-color", "stroke"]);
|
|
307
272
|
var TRANSFORM_FN_NAMES = /* @__PURE__ */ new Set(["translate", "rotate", "scale", "skew"]);
|
|
273
|
+
var PCT_BASED_ATTR_NAMES = /* @__PURE__ */ new Set(["offset-distance", "offsetDistance"]);
|
|
308
274
|
function composeTransformParts(parts, opts) {
|
|
309
275
|
var _a;
|
|
310
276
|
if (!parts) return "";
|
|
@@ -468,6 +434,41 @@ var PixodeskAnimator = (() => {
|
|
|
468
434
|
return cubicBezier(flipped);
|
|
469
435
|
}
|
|
470
436
|
|
|
437
|
+
// ../svg-animator-core/src/PxAnimatorConstants.ts
|
|
438
|
+
var PxAnimatorMode = {
|
|
439
|
+
auto: "auto",
|
|
440
|
+
waapi: "waapi",
|
|
441
|
+
frames: "frames"
|
|
442
|
+
};
|
|
443
|
+
var PxAnimatorEngine = {
|
|
444
|
+
waapi: PxAnimatorMode.waapi,
|
|
445
|
+
frames: PxAnimatorMode.frames
|
|
446
|
+
};
|
|
447
|
+
var PxLoopExtend = {
|
|
448
|
+
/** Segment from the START; the animation is extended BEFORE the first keyframe
|
|
449
|
+
* (intro loops that run before the main timeline begins). */
|
|
450
|
+
before: "before",
|
|
451
|
+
/** DEFAULT — segment from the END; extended AFTER the last keyframe (idle/outro
|
|
452
|
+
* loops that continue once the main timeline has finished). */
|
|
453
|
+
after: "after"
|
|
454
|
+
};
|
|
455
|
+
function getAnimatorConfig(doc) {
|
|
456
|
+
var _a;
|
|
457
|
+
return (doc == null ? void 0 : doc.animator) || ((_a = doc == null ? void 0 : doc.meta) == null ? void 0 : _a.animator);
|
|
458
|
+
}
|
|
459
|
+
function getDefs(doc) {
|
|
460
|
+
var _a;
|
|
461
|
+
if (!doc) return void 0;
|
|
462
|
+
return (_a = getAnimatorConfig(doc)) == null ? void 0 : _a.definitions;
|
|
463
|
+
}
|
|
464
|
+
function getBindings(doc) {
|
|
465
|
+
var _a;
|
|
466
|
+
if (!doc) return void 0;
|
|
467
|
+
const animateById = (_a = getAnimatorConfig(doc)) == null ? void 0 : _a.animateById;
|
|
468
|
+
if (!animateById) return void 0;
|
|
469
|
+
return Object.entries(animateById).map(([id, anim]) => ({ id, animate: anim }));
|
|
470
|
+
}
|
|
471
|
+
|
|
471
472
|
// ../svg-animator-core/src/PxMotionPath.ts
|
|
472
473
|
function getKfTranslate(kf) {
|
|
473
474
|
var _a;
|
|
@@ -801,7 +802,7 @@ var PixodeskAnimator = (() => {
|
|
|
801
802
|
}
|
|
802
803
|
|
|
803
804
|
// ../svg-animator-core/src/PxDefinitions.ts
|
|
804
|
-
var LOOP_JUMP_SHIFT_MS =
|
|
805
|
+
var LOOP_JUMP_SHIFT_MS = 1;
|
|
805
806
|
function deepEqualValue(a, b) {
|
|
806
807
|
if (a === b) return true;
|
|
807
808
|
if (typeof a !== typeof b || a === null || b === null || typeof a !== "object") return false;
|
|
@@ -1050,6 +1051,8 @@ var PixodeskAnimator = (() => {
|
|
|
1050
1051
|
const looped = [];
|
|
1051
1052
|
const separateBoundary = loop.extend !== PxLoopExtend.before;
|
|
1052
1053
|
const originalTerminalKf = keyframes[keyframes.length - 1];
|
|
1054
|
+
let terminalEasingOverride;
|
|
1055
|
+
let hasTerminalEasingOverride = false;
|
|
1053
1056
|
function appendRep(repStart, isReversed, partial) {
|
|
1054
1057
|
var _a2;
|
|
1055
1058
|
let entries;
|
|
@@ -1090,7 +1093,16 @@ var PixodeskAnimator = (() => {
|
|
|
1090
1093
|
const prevKf = looped.length > 0 ? looped[looped.length - 1] : originalTerminalKf;
|
|
1091
1094
|
const isBoundary = separateBoundary && i === 0 && prevKf !== void 0 && Math.abs(((_a2 = prevKf.t) != null ? _a2 : 0) - (repStart + entry.relT * segDuration)) < 1e-9;
|
|
1092
1095
|
if (isBoundary) {
|
|
1093
|
-
if (deepEqualValue(prevKf.v, entry.v))
|
|
1096
|
+
if (deepEqualValue(prevKf.v, entry.v)) {
|
|
1097
|
+
if (looped.length > 0) {
|
|
1098
|
+
prevKf.e = entry.e;
|
|
1099
|
+
prevKf.tangentOut = entry.tangentOut;
|
|
1100
|
+
} else {
|
|
1101
|
+
terminalEasingOverride = entry.e;
|
|
1102
|
+
hasTerminalEasingOverride = true;
|
|
1103
|
+
}
|
|
1104
|
+
continue;
|
|
1105
|
+
}
|
|
1094
1106
|
if (looped.length > 0) {
|
|
1095
1107
|
delete prevKf.tangentIn;
|
|
1096
1108
|
delete prevKf.tangentOut;
|
|
@@ -1171,6 +1183,11 @@ var PixodeskAnimator = (() => {
|
|
|
1171
1183
|
if (loop.extend === PxLoopExtend.before) {
|
|
1172
1184
|
return [...looped, ...keyframes];
|
|
1173
1185
|
} else {
|
|
1186
|
+
if (hasTerminalEasingOverride && keyframes.length > 0) {
|
|
1187
|
+
const head = keyframes.slice(0, -1);
|
|
1188
|
+
const tail = __spreadProps(__spreadValues({}, keyframes[keyframes.length - 1]), { e: terminalEasingOverride });
|
|
1189
|
+
return [...head, tail, ...looped];
|
|
1190
|
+
}
|
|
1174
1191
|
return [...keyframes, ...looped];
|
|
1175
1192
|
}
|
|
1176
1193
|
}
|
|
@@ -1227,6 +1244,9 @@ var PixodeskAnimator = (() => {
|
|
|
1227
1244
|
function normalizeAnimationDefinition(animDef, duration, defs, engine = PxAnimatorEngine.waapi) {
|
|
1228
1245
|
const normalized = {};
|
|
1229
1246
|
for (const [propName, propAnim] of Object.entries(animDef)) {
|
|
1247
|
+
if (propName === "transform" && propAnim.alongPathMode === "offsetPath" && animDef["offsetDistance"] !== void 0) {
|
|
1248
|
+
continue;
|
|
1249
|
+
}
|
|
1230
1250
|
const normalizedKfs = normalizeKeyframes(propName, propAnim, duration, defs);
|
|
1231
1251
|
if (normalizedKfs.length > 0) {
|
|
1232
1252
|
const out = { kfs: normalizedKfs };
|
|
@@ -1420,6 +1440,8 @@ var PixodeskAnimator = (() => {
|
|
|
1420
1440
|
} else if (propName === "d") {
|
|
1421
1441
|
const paths = value && typeof value === "object" && Array.isArray(value.paths) ? value.paths : [];
|
|
1422
1442
|
cssValue = 'path("' + paths.map((bz) => bezierToSvgPath(bz, true)).join("") + '")';
|
|
1443
|
+
} else if (PCT_BASED_ATTR_NAMES.has(propName) && typeof value === "number") {
|
|
1444
|
+
cssValue = value * 100 + "%";
|
|
1423
1445
|
} else {
|
|
1424
1446
|
cssValue = "" + value;
|
|
1425
1447
|
}
|
|
@@ -1488,7 +1510,7 @@ var PixodeskAnimator = (() => {
|
|
|
1488
1510
|
}
|
|
1489
1511
|
return result;
|
|
1490
1512
|
}
|
|
1491
|
-
function createWebApiAnimator(doc, callbacks, rootElement, forceEvenIfHasUnsupportedAttrs) {
|
|
1513
|
+
function createWebApiAnimator(doc, callbacks, rootElement, forceEvenIfHasUnsupportedAttrs, scrollTimeline) {
|
|
1492
1514
|
var _a;
|
|
1493
1515
|
const config = getAnimatorConfig(doc) || {};
|
|
1494
1516
|
if (!rootElement) {
|
|
@@ -1547,7 +1569,12 @@ var PixodeskAnimator = (() => {
|
|
|
1547
1569
|
if (keyframes.length > 0) {
|
|
1548
1570
|
try {
|
|
1549
1571
|
const effect = new KeyframeEffect(element, keyframes, effectOptions);
|
|
1550
|
-
const anim = new Animation(effect, document.timeline);
|
|
1572
|
+
const anim = new Animation(effect, scrollTimeline ? scrollTimeline.timeline : document.timeline);
|
|
1573
|
+
if (scrollTimeline) {
|
|
1574
|
+
const a = anim;
|
|
1575
|
+
if (scrollTimeline.rangeStart) a.rangeStart = scrollTimeline.rangeStart;
|
|
1576
|
+
if (scrollTimeline.rangeEnd) a.rangeEnd = scrollTimeline.rangeEnd;
|
|
1577
|
+
}
|
|
1551
1578
|
if (callbacks == null ? void 0 : callbacks.onFinish) anim.onfinish = () => {
|
|
1552
1579
|
var _a2;
|
|
1553
1580
|
if (finishNotified) return;
|
|
@@ -1641,7 +1668,14 @@ var PixodeskAnimator = (() => {
|
|
|
1641
1668
|
}
|
|
1642
1669
|
};
|
|
1643
1670
|
if (config.trigger) {
|
|
1644
|
-
|
|
1671
|
+
if (config.timelineSource === "scroll") {
|
|
1672
|
+
console.warn("scroll timeline: `animator.trigger` is ignored (triggers do not apply to scroll-driven playback)");
|
|
1673
|
+
} else {
|
|
1674
|
+
setupAnimationTriggers(api, config.trigger);
|
|
1675
|
+
}
|
|
1676
|
+
}
|
|
1677
|
+
if (scrollTimeline) {
|
|
1678
|
+
animations.forEach((a) => a.play());
|
|
1645
1679
|
}
|
|
1646
1680
|
return api;
|
|
1647
1681
|
}
|