@pixodesk/svg-animator-react 1.0.21 → 1.0.22

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.umd.js CHANGED
@@ -2371,6 +2371,7 @@ var PixodeskAnimatorReact = (() => {
2371
2371
  resetOnFinish: px.boolean().optional(),
2372
2372
  definitions: PxDefsSchema.optional(),
2373
2373
  animate: px.record(PxElementAnimationSchema).optional(),
2374
+ timeline: px.string().optional(),
2374
2375
  debug: px.boolean().optional(),
2375
2376
  debugInstName: px.string().optional()
2376
2377
  }));
@@ -2453,6 +2454,17 @@ var PixodeskAnimatorReact = (() => {
2453
2454
  px.object({ value: px.array(PxGradientStopSchema) }),
2454
2455
  px.object({ keyframes: px.array(PxKeyframeSchema) })
2455
2456
  ]);
2457
+ var PxGradientGeometryAnimationSchema = implementsInterface()(px.object({
2458
+ gradientX1: PxPropertyAnimationSchema.optional(),
2459
+ gradientY1: PxPropertyAnimationSchema.optional(),
2460
+ gradientX2: PxPropertyAnimationSchema.optional(),
2461
+ gradientY2: PxPropertyAnimationSchema.optional(),
2462
+ gradientCx: PxPropertyAnimationSchema.optional(),
2463
+ gradientCy: PxPropertyAnimationSchema.optional(),
2464
+ gradientFx: PxPropertyAnimationSchema.optional(),
2465
+ gradientFy: PxPropertyAnimationSchema.optional(),
2466
+ gradientR: PxPropertyAnimationSchema.optional()
2467
+ }));
2456
2468
  var PxFillGradientEffectSchema = implementsInterface()(px.object({
2457
2469
  type: px.enum([PxGradientType.linear, PxGradientType.radial]),
2458
2470
  p1: px.tuple([px.number(), px.number()]).optional(),
@@ -2463,7 +2475,8 @@ var PixodeskAnimatorReact = (() => {
2463
2475
  stops: PxAnimatableGradientStopsSchema.optional(),
2464
2476
  gradientUnits: px.string().optional(),
2465
2477
  spreadMethod: px.string().optional(),
2466
- gradientTransform: px.string().optional()
2478
+ gradientTransform: px.string().optional(),
2479
+ animate: PxGradientGeometryAnimationSchema.optional()
2467
2480
  }));
2468
2481
  var PxStrokeGradientEffectSchema = PxFillGradientEffectSchema;
2469
2482
  var PxTextPathEffectSchema = implementsInterface()(px.object({
@@ -4453,6 +4466,7 @@ var PixodeskAnimatorReact = (() => {
4453
4466
  return rec;
4454
4467
  }
4455
4468
  function readAnimatable(raw) {
4469
+ var _a, _b;
4456
4470
  if (raw === void 0) return {
4457
4471
  kind: "absent"
4458
4472
  /* Absent */
@@ -4460,13 +4474,29 @@ var PixodeskAnimatorReact = (() => {
4460
4474
  if (Array.isArray(raw)) return { kind: "static", value: raw };
4461
4475
  if (typeof raw === "object") {
4462
4476
  const obj = raw;
4463
- if (obj.keyframes) {
4464
- return { kind: "animated", keyframes: obj.keyframes, autoOrient: obj.autoOrient, loop: obj.loop };
4477
+ const kfs = (_a = obj.keyframes) != null ? _a : obj.kfs;
4478
+ if (kfs) {
4479
+ return { kind: "animated", keyframes: kfs.map(normaliseKeyframe), autoOrient: obj.autoOrient, loop: obj.loop };
4465
4480
  }
4466
- if (obj.value !== void 0) return { kind: "static", value: obj.value };
4481
+ const staticValue = (_b = obj.value) != null ? _b : obj.v;
4482
+ if (staticValue !== void 0) return { kind: "static", value: staticValue };
4467
4483
  }
4468
4484
  return { kind: "static", value: raw };
4469
4485
  }
4486
+ function normaliseKeyframe(kf) {
4487
+ if (!kf || typeof kf !== "object") return kf;
4488
+ const k = kf;
4489
+ if (k.t === void 0 && k.v === void 0 && k.e === void 0 && k.to === void 0 && k.ti === void 0) {
4490
+ return kf;
4491
+ }
4492
+ const out = __spreadValues2({}, k);
4493
+ if (out.time === void 0 && k.t !== void 0) out.time = k.t;
4494
+ if (out.value === void 0 && k.v !== void 0) out.value = k.v;
4495
+ if (out.easing === void 0 && k.e !== void 0) out.easing = k.e;
4496
+ if (out.tangentOut === void 0 && k.to !== void 0) out.tangentOut = k.to;
4497
+ if (out.tangentIn === void 0 && k.ti !== void 0) out.tangentIn = k.ti;
4498
+ return out;
4499
+ }
4470
4500
  function readStaticOrigin(raw, ctx) {
4471
4501
  var _a;
4472
4502
  const o = readAnimatable(raw);
@@ -7077,8 +7107,14 @@ var PixodeskAnimatorReact = (() => {
7077
7107
  break;
7078
7108
  }
7079
7109
  case "mouseOver": {
7080
- const mouseOverHandler = () => start();
7081
- const mouseOutHandler = () => handleEndAction();
7110
+ let enteredOnce = false;
7111
+ const mouseOverHandler = () => {
7112
+ enteredOnce = true;
7113
+ start();
7114
+ };
7115
+ const mouseOutHandler = () => {
7116
+ if (enteredOnce) handleEndAction();
7117
+ };
7082
7118
  root.addEventListener("mouseenter", mouseOverHandler);
7083
7119
  root.addEventListener("mouseleave", mouseOutHandler);
7084
7120
  break;
@@ -7095,17 +7131,32 @@ var PixodeskAnimatorReact = (() => {
7095
7131
  break;
7096
7132
  }
7097
7133
  case "scrollIntoView": {
7134
+ const effectiveRatio = (entry) => {
7135
+ var _a, _b;
7136
+ const target = entry.boundingClientRect;
7137
+ const visible = entry.intersectionRect;
7138
+ if (!(target == null ? void 0 : target.height) || !visible) return entry.intersectionRatio;
7139
+ const live = typeof window !== "undefined" && window.innerHeight ? window.innerHeight : Infinity;
7140
+ const declared = (_b = (_a = entry.rootBounds) == null ? void 0 : _a.height) != null ? _b : Infinity;
7141
+ const viewport = Math.min(live, declared);
7142
+ const denom = Math.min(target.height, Number.isFinite(viewport) ? viewport : target.height);
7143
+ return denom > 0 ? visible.height / denom : entry.intersectionRatio;
7144
+ };
7145
+ const thresholdSteps = Array.from({ length: 21 }, (_, i) => i / 20);
7146
+ let wasIntersecting = false;
7098
7147
  const observer = new IntersectionObserver(
7099
7148
  (entries) => {
7100
7149
  entries.forEach((entry) => {
7101
- if (entry.isIntersecting && entry.intersectionRatio >= scrollIntoViewThreshold) {
7150
+ if (entry.isIntersecting && effectiveRatio(entry) >= scrollIntoViewThreshold) {
7151
+ wasIntersecting = true;
7102
7152
  start();
7103
- } else {
7153
+ } else if (wasIntersecting) {
7154
+ wasIntersecting = false;
7104
7155
  handleEndAction();
7105
7156
  }
7106
7157
  });
7107
7158
  },
7108
- { threshold: scrollIntoViewThreshold }
7159
+ { threshold: thresholdSteps }
7109
7160
  );
7110
7161
  observer.observe(root);
7111
7162
  break;