edododraw 0.1.2 → 0.1.3

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.
@@ -3067,9 +3067,7 @@ class CameraController {
3067
3067
  };
3068
3068
  /** Duration heuristic: further travel + bigger zoom change => longer. */
3069
3069
  autoDuration(from, to) {
3070
- const dist2 = Math.hypot(to.cx - from.cx, to.cy - from.cy) * Math.min(from.zoom, to.zoom);
3071
- const zoomRatio = Math.abs(Math.log(to.zoom / from.zoom));
3072
- return clamp(420 + dist2 * 0.12 + zoomRatio * 320, 420, 1300);
3070
+ return autoDuration(from, to);
3073
3071
  }
3074
3072
  // ---- high-level ops -----------------------------------------------------
3075
3073
  fitAll(scene, opts = {}) {
@@ -3109,6 +3107,11 @@ class CameraController {
3109
3107
  this.setImmediate({ cx: cam.cx - dx / cam.zoom, cy: cam.cy - dy / cam.zoom, zoom: cam.zoom });
3110
3108
  }
3111
3109
  }
3110
+ function autoDuration(from, to) {
3111
+ const dist2 = Math.hypot(to.cx - from.cx, to.cy - from.cy) * Math.min(from.zoom, to.zoom);
3112
+ const zoomRatio = Math.abs(Math.log(to.zoom / from.zoom));
3113
+ return clamp(420 + dist2 * 0.12 + zoomRatio * 320, 420, 1300);
3114
+ }
3112
3115
  function lerp(a, b, t) {
3113
3116
  return a + (b - a) * t;
3114
3117
  }
@@ -4276,8 +4279,30 @@ function applyRevealToStep(c, scene, step) {
4276
4279
  const ids = c.targets.flatMap((t) => resolveTargetIds(t, scene));
4277
4280
  if (c.verb === "hide" || c.verb === "fade-out" || c.verb === "remove") {
4278
4281
  step.hide.push(...ids);
4279
- } else {
4280
- step.reveal.push(...ids);
4282
+ return;
4283
+ }
4284
+ step.reveal.push(...ids);
4285
+ const effect = revealEffect(c.with ?? (c.verb !== "show" ? c.verb : void 0));
4286
+ if (effect) {
4287
+ step.revealFx = step.revealFx ?? {};
4288
+ for (const id of ids) step.revealFx[id] = effect;
4289
+ }
4290
+ }
4291
+ function revealEffect(raw) {
4292
+ switch (raw) {
4293
+ case "fade-in":
4294
+ case "fade":
4295
+ return "fade";
4296
+ case "pop":
4297
+ case "pop-in":
4298
+ case "emphasize":
4299
+ return "pop";
4300
+ case "draw-on":
4301
+ case "draw":
4302
+ case "sweep":
4303
+ return "sweep";
4304
+ default:
4305
+ return void 0;
4281
4306
  }
4282
4307
  }
4283
4308
  function cameraDirective(cam, scene, _tokens, timelineProps) {
@@ -5149,6 +5174,11 @@ function ensureEngineStyles(doc = document) {
5149
5174
  injected = true;
5150
5175
  }
5151
5176
  const SVG_NS = "http://www.w3.org/2000/svg";
5177
+ const REVEAL_EFFECT_CLASS = {
5178
+ fade: "edd-reveal-fade",
5179
+ pop: "edd-reveal-pop",
5180
+ sweep: "edd-reveal-sweep"
5181
+ };
5152
5182
  class SvgRenderer {
5153
5183
  container;
5154
5184
  svg;
@@ -5268,6 +5298,23 @@ class SvgRenderer {
5268
5298
  else el.classList.remove("edd-hidden");
5269
5299
  });
5270
5300
  }
5301
+ /**
5302
+ * Play a per-beat reveal animation (`fade` | `pop` | `sweep`) on the named
5303
+ * element groups. Clears any prior reveal classes first and forces a reflow so
5304
+ * re-entering the same beat restarts the animation. `fx` = id -> effect.
5305
+ */
5306
+ playReveal(fx) {
5307
+ const classes = ["edd-reveal-fade", "edd-reveal-pop", "edd-reveal-sweep"];
5308
+ const els = this.svg.querySelectorAll("[data-node],[data-edge]");
5309
+ els.forEach((el) => el.classList.remove(...classes));
5310
+ if (!fx || !Object.keys(fx).length) return;
5311
+ void this.svg.getBoundingClientRect();
5312
+ els.forEach((el) => {
5313
+ const id = el.getAttribute("data-node") ?? el.getAttribute("data-edge");
5314
+ const cls = id ? REVEAL_EFFECT_CLASS[fx[id]] : void 0;
5315
+ if (cls) el.classList.add(cls);
5316
+ });
5317
+ }
5271
5318
  render(scene) {
5272
5319
  this.scene = scene;
5273
5320
  this.bg.setAttribute("fill", scene.meta.background || scene.theme.background);
@@ -5435,6 +5482,7 @@ class TimelinePlayer {
5435
5482
  const step = this.steps[i];
5436
5483
  const scene = this.scene;
5437
5484
  this.renderer.applyVisibility(this.computeHidden(i));
5485
+ if (animate) this.renderer.playReveal(step.revealFx);
5438
5486
  this.annotations.render(scene, [...scene.annotations, ...step.annotations], animate);
5439
5487
  this.emit();
5440
5488
  if (step.camera) {
@@ -6119,4 +6167,4 @@ export {
6119
6167
  deleteElements as y,
6120
6168
  dist as z
6121
6169
  };
6122
- //# sourceMappingURL=EdodoDraw-C3Yd1I9B.js.map
6170
+ //# sourceMappingURL=EdodoDraw-BCfKu4Q3.js.map