@pixodesk/svg-animator-web 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.js CHANGED
@@ -634,6 +634,7 @@ var PxAnimatorConfigSchema = implementsInterface()(px.object({
634
634
  resetOnFinish: px.boolean().optional(),
635
635
  definitions: PxDefsSchema.optional(),
636
636
  animate: px.record(PxElementAnimationSchema).optional(),
637
+ timeline: px.string().optional(),
637
638
  debug: px.boolean().optional(),
638
639
  debugInstName: px.string().optional()
639
640
  }));
@@ -725,6 +726,17 @@ var PxAnimatableGradientStopsSchema = px.union([
725
726
  px.object({ value: px.array(PxGradientStopSchema) }),
726
727
  px.object({ keyframes: px.array(PxKeyframeSchema) })
727
728
  ]);
729
+ var PxGradientGeometryAnimationSchema = implementsInterface()(px.object({
730
+ gradientX1: PxPropertyAnimationSchema.optional(),
731
+ gradientY1: PxPropertyAnimationSchema.optional(),
732
+ gradientX2: PxPropertyAnimationSchema.optional(),
733
+ gradientY2: PxPropertyAnimationSchema.optional(),
734
+ gradientCx: PxPropertyAnimationSchema.optional(),
735
+ gradientCy: PxPropertyAnimationSchema.optional(),
736
+ gradientFx: PxPropertyAnimationSchema.optional(),
737
+ gradientFy: PxPropertyAnimationSchema.optional(),
738
+ gradientR: PxPropertyAnimationSchema.optional()
739
+ }));
728
740
  var PxFillGradientEffectSchema = implementsInterface()(px.object({
729
741
  type: px.enum([PxGradientType.linear, PxGradientType.radial]),
730
742
  p1: px.tuple([px.number(), px.number()]).optional(),
@@ -735,7 +747,8 @@ var PxFillGradientEffectSchema = implementsInterface()(px.object({
735
747
  stops: PxAnimatableGradientStopsSchema.optional(),
736
748
  gradientUnits: px.string().optional(),
737
749
  spreadMethod: px.string().optional(),
738
- gradientTransform: px.string().optional()
750
+ gradientTransform: px.string().optional(),
751
+ animate: PxGradientGeometryAnimationSchema.optional()
739
752
  }));
740
753
  var PxStrokeGradientEffectSchema = PxFillGradientEffectSchema;
741
754
  var PxTextPathEffectSchema = implementsInterface()(px.object({
@@ -2732,6 +2745,7 @@ function partsRecord(part, value, origin) {
2732
2745
  return rec;
2733
2746
  }
2734
2747
  function readAnimatable(raw) {
2748
+ var _a, _b;
2735
2749
  if (raw === void 0) return {
2736
2750
  kind: "absent"
2737
2751
  /* Absent */
@@ -2739,13 +2753,29 @@ function readAnimatable(raw) {
2739
2753
  if (Array.isArray(raw)) return { kind: "static", value: raw };
2740
2754
  if (typeof raw === "object") {
2741
2755
  const obj = raw;
2742
- if (obj.keyframes) {
2743
- return { kind: "animated", keyframes: obj.keyframes, autoOrient: obj.autoOrient, loop: obj.loop };
2756
+ const kfs = (_a = obj.keyframes) != null ? _a : obj.kfs;
2757
+ if (kfs) {
2758
+ return { kind: "animated", keyframes: kfs.map(normaliseKeyframe), autoOrient: obj.autoOrient, loop: obj.loop };
2744
2759
  }
2745
- if (obj.value !== void 0) return { kind: "static", value: obj.value };
2760
+ const staticValue = (_b = obj.value) != null ? _b : obj.v;
2761
+ if (staticValue !== void 0) return { kind: "static", value: staticValue };
2746
2762
  }
2747
2763
  return { kind: "static", value: raw };
2748
2764
  }
2765
+ function normaliseKeyframe(kf) {
2766
+ if (!kf || typeof kf !== "object") return kf;
2767
+ const k = kf;
2768
+ if (k.t === void 0 && k.v === void 0 && k.e === void 0 && k.to === void 0 && k.ti === void 0) {
2769
+ return kf;
2770
+ }
2771
+ const out = __spreadValues2({}, k);
2772
+ if (out.time === void 0 && k.t !== void 0) out.time = k.t;
2773
+ if (out.value === void 0 && k.v !== void 0) out.value = k.v;
2774
+ if (out.easing === void 0 && k.e !== void 0) out.easing = k.e;
2775
+ if (out.tangentOut === void 0 && k.to !== void 0) out.tangentOut = k.to;
2776
+ if (out.tangentIn === void 0 && k.ti !== void 0) out.tangentIn = k.ti;
2777
+ return out;
2778
+ }
2749
2779
  function readStaticOrigin(raw, ctx) {
2750
2780
  var _a;
2751
2781
  const o = readAnimatable(raw);
@@ -5698,8 +5728,14 @@ function setupAnimationTriggers(api, config) {
5698
5728
  break;
5699
5729
  }
5700
5730
  case "mouseOver": {
5701
- const mouseOverHandler = () => start();
5702
- const mouseOutHandler = () => handleEndAction();
5731
+ let enteredOnce = false;
5732
+ const mouseOverHandler = () => {
5733
+ enteredOnce = true;
5734
+ start();
5735
+ };
5736
+ const mouseOutHandler = () => {
5737
+ if (enteredOnce) handleEndAction();
5738
+ };
5703
5739
  root.addEventListener("mouseenter", mouseOverHandler);
5704
5740
  root.addEventListener("mouseleave", mouseOutHandler);
5705
5741
  break;
@@ -5716,17 +5752,32 @@ function setupAnimationTriggers(api, config) {
5716
5752
  break;
5717
5753
  }
5718
5754
  case "scrollIntoView": {
5755
+ const effectiveRatio = (entry) => {
5756
+ var _a, _b;
5757
+ const target = entry.boundingClientRect;
5758
+ const visible = entry.intersectionRect;
5759
+ if (!(target == null ? void 0 : target.height) || !visible) return entry.intersectionRatio;
5760
+ const live = typeof window !== "undefined" && window.innerHeight ? window.innerHeight : Infinity;
5761
+ const declared = (_b = (_a = entry.rootBounds) == null ? void 0 : _a.height) != null ? _b : Infinity;
5762
+ const viewport = Math.min(live, declared);
5763
+ const denom = Math.min(target.height, Number.isFinite(viewport) ? viewport : target.height);
5764
+ return denom > 0 ? visible.height / denom : entry.intersectionRatio;
5765
+ };
5766
+ const thresholdSteps = Array.from({ length: 21 }, (_, i) => i / 20);
5767
+ let wasIntersecting = false;
5719
5768
  const observer = new IntersectionObserver(
5720
5769
  (entries) => {
5721
5770
  entries.forEach((entry) => {
5722
- if (entry.isIntersecting && entry.intersectionRatio >= scrollIntoViewThreshold) {
5771
+ if (entry.isIntersecting && effectiveRatio(entry) >= scrollIntoViewThreshold) {
5772
+ wasIntersecting = true;
5723
5773
  start();
5724
- } else {
5774
+ } else if (wasIntersecting) {
5775
+ wasIntersecting = false;
5725
5776
  handleEndAction();
5726
5777
  }
5727
5778
  });
5728
5779
  },
5729
- { threshold: scrollIntoViewThreshold }
5780
+ { threshold: thresholdSteps }
5730
5781
  );
5731
5782
  observer.observe(root);
5732
5783
  break;