@@ -284,9 +284,9 @@ const isAnimating = elem.getAnimations().some(
284
284
<div class='example'>
285
285
<pre class='lang-javascript'>
286
286
// Pause all existing animations in the document
287
- document.getAnimations().forEach(
288
- animation => animation .pause()
289
- );
287
+ for (const animation of document.getAnimations()) {
288
+ animation.pause()
289
+ }
290
290
</pre>
291
291
</div>
292
292
@@ -318,13 +318,16 @@ elem.animate({ transform: 'scale(0)', opacity: 0 }, 300);
318
318
<div class='example'>
319
319
<pre class='lang-javascript'>
320
320
// Print the id of any opacity animations on elem
321
- elem.getAnimations().filter(
322
- animation =>
321
+ for (const animation of elem.getAnimations()) {
322
+ if (
323
323
animation.effect instanceof KeyframeEffect &&
324
- animation.effect.getKeyframes().some(
325
- frame => frame.hasOwnProperty('opacity' )
326
- )
327
- ).forEach(animation => console.log(animation.id));
324
+ animation.effect
325
+ .getKeyframes()
326
+ .some(frame => frame.hasOwnProperty('opacity' ))
327
+ ) {
328
+ console.log(animation.id);
329
+ }
330
+ }
328
331
</pre>
329
332
</div>
330
333
@@ -334,16 +337,18 @@ elem.getAnimations().filter(
334
337
<div class='example'>
335
338
<pre class='lang-javascript'>
336
339
// Slow down and replay any transform animations
337
- elem.getAnimations().filter(
340
+ const transformAnimations = elem.getAnimations().filter(
338
341
animation =>
339
342
animation.effect instanceof KeyframeEffect &&
340
343
animation.effect.getKeyframes().some(
341
344
frame => frame.hasOwnProperty('transform' )
342
345
)
343
- ).forEach(animation => {
346
+ );
347
+
348
+ for (const animation of transformAnimations) {
344
349
animation.currentTime = 0;
345
350
animation.updatePlaybackRate(0.5);
346
- });
351
+ }
347
352
</pre>
348
353
</div>
349
354
@@ -355,18 +360,16 @@ elem.getAnimations().filter(
355
360
<div class='example'>
356
361
<pre class='lang-javascript'>
357
362
// Seek to the half-way point of an animation and check that the opacity is 50%
358
- elem.getAnimations().forEach(
359
- animation =>
360
- animation.currentTime =
361
- animation.effect.getComputedTiming().delay +
362
- animation.effect.getComputedTiming().activeDuration / 2;
363
- );
363
+ for (const animation of elem.getAnimations()) {
364
+ const { delay, activeDuration } = animation.effect.getComputedTiming();
365
+ animation.currentTime = delay + activeDuration / 2;
366
+ }
364
367
assert.strictEqual(getComputedStyle(elem).opacity, '0.5' );
365
368
366
369
// Check that the loading screen is hidden after the animations finish
367
- elem.getAnimations().forEach(
368
- animation => animation .finish()
369
- );
370
+ for (const animation of elem.getAnimations()) {
371
+ animation.finish();
372
+ }
370
373
// Wait one frame so that event handlers have a chance to run
371
374
requestAnimationFrame(() => {
372
375
assert.strictEqual(
0 commit comments