evalstate HF Staff commited on
Commit
47bfffc
·
verified ·
1 Parent(s): b5c4e86

Add parent-controlled visibility hooks to step-sequence animations

Browse files
2026/mcp-connect/animations/shared/diagram-helpers.js CHANGED
@@ -143,14 +143,16 @@ function runStepSequence(steps, { initialDelay = 100, stepPause, startOnLoad = t
143
  }, initialDelay);
144
  }
145
 
146
- const start = () => {
147
  runId++;
148
-
149
  if (animationTimer) {
150
  clearTimeout(animationTimer);
151
  animationTimer = null;
152
  }
 
153
 
 
 
154
  currentStep = 0;
155
  runStep(runId);
156
  };
@@ -171,4 +173,18 @@ function runStepSequence(steps, { initialDelay = 100, stepPause, startOnLoad = t
171
  } else {
172
  start();
173
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
174
  }
 
143
  }, initialDelay);
144
  }
145
 
146
+ const stop = () => {
147
  runId++;
 
148
  if (animationTimer) {
149
  clearTimeout(animationTimer);
150
  animationTimer = null;
151
  }
152
+ };
153
 
154
+ const start = () => {
155
+ stop();
156
  currentStep = 0;
157
  runStep(runId);
158
  };
 
173
  } else {
174
  start();
175
  }
176
+
177
+ // Parent-controlled visibility for embedded slide iframes.
178
+ window.addEventListener('message', (event) => {
179
+ const data = event.data;
180
+ if (!data || data.type !== 'marp-slide-visibility') {
181
+ return;
182
+ }
183
+
184
+ if (data.active) {
185
+ start();
186
+ } else {
187
+ stop();
188
+ }
189
+ });
190
  }