1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
|
<!doctype html>
<meta charset=utf-8>
<title>The effect value of a keyframe effect: Applying the iteration composite
operation</title>
<link rel="help" href="https://drafts.csswg.org/web-animations/#the-effect-value-of-a-keyframe-animation-effect">
<link rel="help" href="https://drafts.csswg.org/web-animations/#effect-accumulation-section">
<script src=/resources/testharness.js></script>
<script src=/resources/testharnessreport.js></script>
<script src="../../testcommon.js"></script>
<div id="log"></div>
<script>
'use strict';
test(t => {
const div = createDiv(t);
const anim =
div.animate({ alignContent: ['flex-start', 'flex-end'] },
{ duration: 100 * MS_PER_SEC,
easing: 'linear',
iterations: 10,
iterationComposite: 'accumulate' });
anim.currentTime = anim.effect.getComputedTiming().duration / 2;
assert_equals(getComputedStyle(div).alignContent, 'flex-end',
'Animated align-content style at 50s of the first iteration');
anim.currentTime = anim.effect.getComputedTiming().duration * 2;
assert_equals(getComputedStyle(div).alignContent, 'flex-start',
'Animated align-content style at 0s of the third iteration');
anim.currentTime += anim.effect.getComputedTiming().duration / 2;
assert_equals(getComputedStyle(div).alignContent, 'flex-end',
'Animated align-content style at 50s of the third iteration');
}, 'iteration composition of discrete type animation (align-content)');
test(t => {
const div = createDiv(t);
const anim =
div.animate({ marginLeft: ['0px', '10px'] },
{ duration: 100 * MS_PER_SEC,
easing: 'linear',
iterations: 10,
iterationComposite: 'accumulate' });
anim.pause();
anim.currentTime = anim.effect.getComputedTiming().duration / 2;
assert_equals(getComputedStyle(div).marginLeft, '5px',
'Animated margin-left style at 50s of the first iteration');
anim.currentTime = anim.effect.getComputedTiming().duration * 2;
assert_equals(getComputedStyle(div).marginLeft, '20px',
'Animated margin-left style at 0s of the third iteration');
anim.currentTime += anim.effect.getComputedTiming().duration / 2;
assert_equals(getComputedStyle(div).marginLeft, '25px',
'Animated margin-left style at 50s of the third iteration');
}, 'iteration composition of <length> type animation');
test(t => {
const parent = createDiv(t);
parent.style.width = '100px';
const div = createDiv(t);
parent.appendChild(div);
const anim =
div.animate({ width: ['0%', '50%'] },
{ duration: 100 * MS_PER_SEC,
easing: 'linear',
iterations: 10,
iterationComposite: 'accumulate' });
anim.pause();
anim.currentTime = anim.effect.getComputedTiming().duration / 2;
assert_equals(getComputedStyle(div).width, '25px',
'Animated width style at 50s of the first iteration');
anim.currentTime = anim.effect.getComputedTiming().duration * 2;
assert_equals(getComputedStyle(div).width, '100px',
'Animated width style at 0s of the third iteration');
anim.currentTime += anim.effect.getComputedTiming().duration / 2;
assert_equals(getComputedStyle(div).width, '125px',
'Animated width style at 50s of the third iteration');
}, 'iteration composition of <percentage> type animation');
test(t => {
const div = createDiv(t);
const anim =
div.animate({ color: ['rgb(0, 0, 0)', 'rgb(120, 120, 120)'] },
{ duration: 100 * MS_PER_SEC,
easing: 'linear',
iterations: 10,
iterationComposite: 'accumulate' });
anim.pause();
anim.currentTime = anim.effect.getComputedTiming().duration / 2;
assert_equals(getComputedStyle(div).color, 'rgb(60, 60, 60)',
'Animated color style at 50s of the first iteration');
anim.currentTime = anim.effect.getComputedTiming().duration * 2;
assert_equals(getComputedStyle(div).color, 'rgb(240, 240, 240)',
'Animated color style at 0s of the third iteration');
anim.currentTime += anim.effect.getComputedTiming().duration / 2;
assert_equals(getComputedStyle(div).color, 'rgb(255, 255, 255)',
'Animated color style at 50s of the third iteration');
}, 'iteration composition of <color> type animation');
test(t => {
const div = createDiv(t);
const anim =
div.animate({ color: ['rgb(0, 120, 0)', 'rgb(60, 60, 60)'] },
{ duration: 100 * MS_PER_SEC,
easing: 'linear',
iterations: 10,
iterationComposite: 'accumulate' });
anim.pause();
anim.currentTime = anim.effect.getComputedTiming().duration / 2;
assert_equals(getComputedStyle(div).color, 'rgb(30, 90, 30)',
'Animated color style at 50s of the first iteration');
anim.currentTime = anim.effect.getComputedTiming().duration * 2;
assert_equals(getComputedStyle(div).color, 'rgb(120, 240, 120)',
'Animated color style at 0s of the third iteration');
anim.currentTime += anim.effect.getComputedTiming().duration / 2;
// The green color is (240 + 180) / 2 = 210
assert_equals(getComputedStyle(div).color, 'rgb(150, 210, 150)',
'Animated color style at 50s of the third iteration');
}, 'iteration composition of <color> type animation that green component is ' +
'decreasing');
test(t => {
const div = createDiv(t);
const anim =
div.animate({ flexGrow: [0, 10] },
{ duration: 100 * MS_PER_SEC,
easing: 'linear',
iterations: 10,
iterationComposite: 'accumulate' });
anim.pause();
anim.currentTime = anim.effect.getComputedTiming().duration / 2;
assert_equals(getComputedStyle(div).flexGrow, '5',
'Animated flex-grow style at 50s of the first iteration');
anim.currentTime = anim.effect.getComputedTiming().duration * 2;
assert_equals(getComputedStyle(div).flexGrow, '20',
'Animated flex-grow style at 0s of the third iteration');
anim.currentTime += anim.effect.getComputedTiming().duration / 2;
assert_equals(getComputedStyle(div).flexGrow, '25',
'Animated flex-grow style at 50s of the third iteration');
}, 'iteration composition of <number> type animation');
test(t => {
const div = createDiv(t);
div.style.position = 'absolute';
const anim =
div.animate({ clip: ['rect(0px, 0px, 0px, 0px)',
'rect(10px, 10px, 10px, 10px)'] },
{ duration: 100 * MS_PER_SEC,
easing: 'linear',
iterations: 10,
iterationComposite: 'accumulate' });
anim.pause();
anim.currentTime = anim.effect.getComputedTiming().duration / 2;
assert_equals(getComputedStyle(div).clip, 'rect(5px, 5px, 5px, 5px)',
'Animated clip style at 50s of the first iteration');
anim.currentTime = anim.effect.getComputedTiming().duration * 2;
assert_equals(getComputedStyle(div).clip, 'rect(20px, 20px, 20px, 20px)',
'Animated clip style at 0s of the third iteration');
anim.currentTime += anim.effect.getComputedTiming().duration / 2;
assert_equals(getComputedStyle(div).clip, 'rect(25px, 25px, 25px, 25px)',
'Animated clip style at 50s of the third iteration');
}, 'iteration composition of <shape> type animation');
test(t => {
const div = createDiv(t);
const anim =
div.animate({ width: ['calc(0vw + 0px)', 'calc(0vw + 10px)'] },
{ duration: 100 * MS_PER_SEC,
easing: 'linear',
iterations: 10,
iterationComposite: 'accumulate' });
anim.pause();
anim.currentTime = anim.effect.getComputedTiming().duration / 2;
assert_equals(getComputedStyle(div).width, '5px',
'Animated calc width style at 50s of the first iteration');
anim.currentTime = anim.effect.getComputedTiming().duration * 2;
assert_equals(getComputedStyle(div).width, '20px',
'Animated calc width style at 0s of the third iteration');
anim.currentTime += anim.effect.getComputedTiming().duration / 2;
assert_equals(getComputedStyle(div).width, '25px',
'Animated calc width style at 50s of the third iteration');
}, 'iteration composition of <calc()> value animation');
test(t => {
const parent = createDiv(t);
parent.style.width = '100px';
const div = createDiv(t);
parent.appendChild(div);
const anim =
div.animate({ width: ['calc(0% + 0px)', 'calc(10% + 10px)'] },
{ duration: 100 * MS_PER_SEC,
easing: 'linear',
iterations: 10,
iterationComposite: 'accumulate' });
anim.pause();
anim.currentTime = anim.effect.getComputedTiming().duration / 2;
assert_equals(getComputedStyle(div).width, '10px',
// 100px * 5% + 5px
'Animated calc width style at 50s of the first iteration');
anim.currentTime = anim.effect.getComputedTiming().duration * 2;
assert_equals(getComputedStyle(div).width,
'40px', // 100px * (10% + 10%) + (10px + 10px)
'Animated calc width style at 0s of the third iteration');
anim.currentTime += anim.effect.getComputedTiming().duration / 2;
assert_equals(getComputedStyle(div).width,
'50px', // (40px + 60px) / 2
'Animated calc width style at 50s of the third iteration');
}, 'iteration composition of <calc()> value animation that the values can\'t' +
'be reduced');
test(t => {
const div = createDiv(t);
const anim =
div.animate({ opacity: [0, 0.4] },
{ duration: 100 * MS_PER_SEC,
easing: 'linear',
iterations: 10,
iterationComposite: 'accumulate' });
anim.pause();
anim.currentTime = anim.effect.getComputedTiming().duration / 2;
assert_equals(getComputedStyle(div).opacity, '0.2',
'Animated opacity style at 50s of the first iteration');
anim.currentTime = anim.effect.getComputedTiming().duration * 2;
assert_equals(getComputedStyle(div).opacity, '0.8',
'Animated opacity style at 0s of the third iteration');
anim.currentTime += anim.effect.getComputedTiming().duration / 2;
assert_equals(getComputedStyle(div).opacity, '1', // (0.8 + 1.2) * 0.5
'Animated opacity style at 50s of the third iteration');
}, 'iteration composition of opacity animation');
test(t => {
const div = createDiv(t);
const anim =
div.animate({ boxShadow: ['rgb(0, 0, 0) 0px 0px 0px 0px',
'rgb(120, 120, 120) 10px 10px 10px 0px'] },
{ duration: 100 * MS_PER_SEC,
easing: 'linear',
iterations: 10,
iterationComposite: 'accumulate' });
anim.pause();
anim.currentTime = anim.effect.getComputedTiming().duration / 2;
assert_equals(getComputedStyle(div).boxShadow,
'rgb(60, 60, 60) 5px 5px 5px 0px',
'Animated box-shadow style at 50s of the first iteration');
anim.currentTime = anim.effect.getComputedTiming().duration * 2;
assert_equals(getComputedStyle(div).boxShadow,
'rgb(240, 240, 240) 20px 20px 20px 0px',
'Animated box-shadow style at 0s of the third iteration');
anim.currentTime += anim.effect.getComputedTiming().duration / 2;
assert_equals(getComputedStyle(div).boxShadow,
'rgb(255, 255, 255) 25px 25px 25px 0px',
'Animated box-shadow style at 50s of the third iteration');
}, 'iteration composition of box-shadow animation');
test(t => {
const div = createDiv(t);
const anim =
div.animate({ filter: ['blur(0px)', 'blur(10px)'] },
{ duration: 100 * MS_PER_SEC,
easing: 'linear',
iterations: 10,
iterationComposite: 'accumulate' });
anim.pause();
anim.currentTime = anim.effect.getComputedTiming().duration / 2;
assert_equals(getComputedStyle(div).filter, 'blur(5px)',
'Animated filter blur style at 50s of the first iteration');
anim.currentTime = anim.effect.getComputedTiming().duration * 2;
assert_equals(getComputedStyle(div).filter, 'blur(20px)',
'Animated filter blur style at 0s of the third iteration');
anim.currentTime += anim.effect.getComputedTiming().duration / 2;
assert_equals(getComputedStyle(div).filter, 'blur(25px)',
'Animated filter blur style at 50s of the third iteration');
}, 'iteration composition of filter blur animation');
test(t => {
const div = createDiv(t);
const anim =
div.animate({ filter: ['brightness(1)',
'brightness(180%)'] },
{ duration: 100 * MS_PER_SEC,
easing: 'linear',
iterations: 10,
iterationComposite: 'accumulate' });
anim.pause();
anim.currentTime = anim.effect.getComputedTiming().duration / 2;
assert_equals(getComputedStyle(div).filter,
'brightness(1.4)',
'Animated filter brightness style at 50s of the first iteration');
anim.currentTime = anim.effect.getComputedTiming().duration * 2;
assert_equals(getComputedStyle(div).filter,
'brightness(2.6)', // brightness(1) + brightness(0.8) + brightness(0.8)
'Animated filter brightness style at 0s of the third iteration');
anim.currentTime += anim.effect.getComputedTiming().duration / 2;
assert_equals(getComputedStyle(div).filter,
'brightness(3)', // (brightness(2.6) + brightness(3.4)) * 0.5
'Animated filter brightness style at 50s of the third iteration');
}, 'iteration composition of filter brightness for different unit animation');
test(t => {
const div = createDiv(t);
const anim =
div.animate({ filter: ['brightness(0)',
'brightness(1)'] },
{ duration: 100 * MS_PER_SEC,
easing: 'linear',
iterations: 10,
iterationComposite: 'accumulate' });
anim.pause();
anim.currentTime = anim.effect.getComputedTiming().duration / 2;
assert_equals(getComputedStyle(div).filter,
'brightness(0.5)',
'Animated filter brightness style at 50s of the first iteration');
anim.currentTime = anim.effect.getComputedTiming().duration * 2;
assert_equals(getComputedStyle(div).filter,
'brightness(0)', // brightness(1) is an identity element, not accumulated.
'Animated filter brightness style at 0s of the third iteration');
anim.currentTime += anim.effect.getComputedTiming().duration / 2;
assert_equals(getComputedStyle(div).filter,
'brightness(0.5)', // brightness(1) is an identity element, not accumulated.
'Animated filter brightness style at 50s of the third iteration');
}, 'iteration composition of filter brightness animation');
test(t => {
const div = createDiv(t);
const anim =
div.animate({ filter: ['drop-shadow(rgb(0, 0, 0) 0px 0px 0px)',
'drop-shadow(rgb(120, 120, 120) 10px 10px 10px)'] },
{ duration: 100 * MS_PER_SEC,
easing: 'linear',
iterations: 10,
iterationComposite: 'accumulate' });
anim.pause();
anim.currentTime = anim.effect.getComputedTiming().duration / 2;
assert_equals(getComputedStyle(div).filter,
'drop-shadow(rgb(60, 60, 60) 5px 5px 5px)',
'Animated filter drop-shadow style at 50s of the first iteration');
anim.currentTime = anim.effect.getComputedTiming().duration * 2;
assert_equals(getComputedStyle(div).filter,
'drop-shadow(rgb(240, 240, 240) 20px 20px 20px)',
'Animated filter drop-shadow style at 0s of the third iteration');
anim.currentTime += anim.effect.getComputedTiming().duration / 2;
assert_equals(getComputedStyle(div).filter,
'drop-shadow(rgb(255, 255, 255) 25px 25px 25px)',
'Animated filter drop-shadow style at 50s of the third iteration');
}, 'iteration composition of filter drop-shadow animation');
test(t => {
const div = createDiv(t);
const anim =
div.animate({ filter: ['brightness(1) contrast(1)',
'brightness(2) contrast(2)'] },
{ duration: 100 * MS_PER_SEC,
easing: 'linear',
iterations: 10,
iterationComposite: 'accumulate' });
anim.pause();
anim.currentTime = anim.effect.getComputedTiming().duration / 2;
assert_equals(getComputedStyle(div).filter,
'brightness(1.5) contrast(1.5)',
'Animated filter list at 50s of the first iteration');
anim.currentTime = anim.effect.getComputedTiming().duration * 2;
assert_equals(getComputedStyle(div).filter,
'brightness(3) contrast(3)',
'Animated filter list at 0s of the third iteration');
anim.currentTime += anim.effect.getComputedTiming().duration / 2;
assert_equals(getComputedStyle(div).filter,
'brightness(3.5) contrast(3.5)',
'Animated filter list at 50s of the third iteration');
}, 'iteration composition of same filter list animation');
test(t => {
const div = createDiv(t);
const anim =
div.animate({ filter: ['brightness(1) contrast(1)',
'contrast(2) brightness(2)'] },
{ duration: 100 * MS_PER_SEC,
easing: 'linear',
iterations: 10,
iterationComposite: 'accumulate' });
anim.pause();
anim.currentTime = anim.effect.getComputedTiming().duration / 2;
assert_equals(getComputedStyle(div).filter,
'contrast(2) brightness(2)', // discrete
'Animated filter list at 50s of the first iteration');
anim.currentTime = anim.effect.getComputedTiming().duration * 2;
assert_equals(getComputedStyle(div).filter,
// We can't accumulate 'contrast(2) brightness(2)' onto
// the first list 'brightness(1) contrast(1)' because of
// mismatch of the order.
'brightness(1) contrast(1)',
'Animated filter list at 0s of the third iteration');
anim.currentTime += anim.effect.getComputedTiming().duration / 2;
assert_equals(getComputedStyle(div).filter,
// We *can* accumulate 'contrast(2) brightness(2)' onto
// the same list 'contrast(2) brightness(2)' here.
'contrast(4) brightness(4)', // discrete
'Animated filter list at 50s of the third iteration');
}, 'iteration composition of discrete filter list because of mismatch ' +
'of the order');
test(t => {
const div = createDiv(t);
const anim =
div.animate({ filter: ['sepia(0)',
'sepia(1) contrast(2)'] },
{ duration: 100 * MS_PER_SEC,
easing: 'linear',
iterations: 10,
iterationComposite: 'accumulate' });
anim.pause();
anim.currentTime = anim.effect.getComputedTiming().duration / 2;
assert_equals(getComputedStyle(div).filter,
'sepia(0.5) contrast(1.5)',
'Animated filter list at 50s of the first iteration');
anim.currentTime = anim.effect.getComputedTiming().duration * 2;
assert_equals(getComputedStyle(div).filter,
'sepia(1) contrast(3)',
'Animated filter list at 0s of the third iteration');
anim.currentTime += anim.effect.getComputedTiming().duration / 2;
assert_equals(getComputedStyle(div).filter,
'sepia(1) contrast(3.5)',
'Animated filter list at 50s of the third iteration');
}, 'iteration composition of different length filter list animation');
test(t => {
const div = createDiv(t);
const anim =
div.animate({ transform: ['rotate(0deg)', 'rotate(180deg)'] },
{ duration: 100 * MS_PER_SEC,
easing: 'linear',
iterations: 10,
iterationComposite: 'accumulate' });
anim.pause();
anim.currentTime = anim.effect.getComputedTiming().duration / 2;
assert_matrix_equals(getComputedStyle(div).transform,
'matrix(0, 1, -1, 0, 0, 0)', // rotate(90deg)
'Animated transform(rotate) style at 50s of the first iteration');
anim.currentTime = anim.effect.getComputedTiming().duration * 2;
assert_matrix_equals(getComputedStyle(div).transform,
'matrix(1, 0, 0, 1, 0, 0)', // rotate(360deg)
'Animated transform(rotate) style at 0s of the third iteration');
anim.currentTime += anim.effect.getComputedTiming().duration / 2;
assert_matrix_equals(getComputedStyle(div).transform,
'matrix(0, 1, -1, 0, 0, 0)', // rotate(450deg)
'Animated transform(rotate) style at 50s of the third iteration');
}, 'iteration composition of transform(rotate) animation');
test(t => {
const div = createDiv(t);
const anim =
div.animate({ transform: ['scale(0)', 'scale(1)'] },
{ duration: 100 * MS_PER_SEC,
easing: 'linear',
iterations: 10,
iterationComposite: 'accumulate' });
anim.pause();
anim.currentTime = anim.effect.getComputedTiming().duration / 2;
assert_matrix_equals(getComputedStyle(div).transform,
'matrix(0.5, 0, 0, 0.5, 0, 0)', // scale(0.5)
'Animated transform(scale) style at 50s of the first iteration');
anim.currentTime = anim.effect.getComputedTiming().duration * 2;
assert_matrix_equals(getComputedStyle(div).transform,
'matrix(0, 0, 0, 0, 0, 0)', // scale(0); scale(1) is an identity element,
// not accumulated.
'Animated transform(scale) style at 0s of the third iteration');
anim.currentTime += anim.effect.getComputedTiming().duration / 2;
assert_matrix_equals(getComputedStyle(div).transform,
'matrix(0.5, 0, 0, 0.5, 0, 0)', // scale(0.5); scale(1) an identity
// element, not accumulated.
'Animated transform(scale) style at 50s of the third iteration');
}, 'iteration composition of transform: [ scale(0), scale(1) ] animation');
test(t => {
const div = createDiv(t);
const anim =
div.animate({ transform: ['scale(1)', 'scale(2)'] },
{ duration: 100 * MS_PER_SEC,
easing: 'linear',
iterations: 10,
iterationComposite: 'accumulate' });
anim.pause();
anim.currentTime = anim.effect.getComputedTiming().duration / 2;
assert_matrix_equals(getComputedStyle(div).transform,
'matrix(1.5, 0, 0, 1.5, 0, 0)', // scale(1.5)
'Animated transform(scale) style at 50s of the first iteration');
anim.currentTime = anim.effect.getComputedTiming().duration * 2;
assert_matrix_equals(getComputedStyle(div).transform,
'matrix(3, 0, 0, 3, 0, 0)', // scale(1 + (2 -1) + (2 -1))
'Animated transform(scale) style at 0s of the third iteration');
anim.currentTime += anim.effect.getComputedTiming().duration / 2;
assert_matrix_equals(getComputedStyle(div).transform,
'matrix(3.5, 0, 0, 3.5, 0, 0)', // (scale(3) + scale(4)) * 0.5
'Animated transform(scale) style at 50s of the third iteration');
}, 'iteration composition of transform: [ scale(1), scale(2) ] animation');
test(t => {
const div = createDiv(t);
const anim =
div.animate({ transform: ['scale(0)', 'scale(2)'] },
{ duration: 100 * MS_PER_SEC,
easing: 'linear',
iterations: 10,
iterationComposite: 'accumulate' });
anim.pause();
anim.currentTime = anim.effect.getComputedTiming().duration / 2;
assert_matrix_equals(getComputedStyle(div).transform,
'matrix(1, 0, 0, 1, 0, 0)', // scale(1)
'Animated transform(scale) style at 50s of the first iteration');
anim.currentTime = anim.effect.getComputedTiming().duration * 2;
assert_matrix_equals(getComputedStyle(div).transform,
'matrix(2, 0, 0, 2, 0, 0)', // (scale(0) + scale(2-1)*2)
'Animated transform(scale) style at 0s of the third iteration');
anim.currentTime += anim.effect.getComputedTiming().duration / 2;
assert_matrix_equals(getComputedStyle(div).transform,
'matrix(3, 0, 0, 3, 0, 0)', // (scale(2) + scale(4)) * 0.5
'Animated transform(scale) style at 50s of the third iteration');
}, 'iteration composition of transform: scale(2) animation');
test(t => {
const div = createDiv(t);
const anim =
div.animate({ transform: ['rotate(0deg) translateX(0px)',
'rotate(180deg) translateX(10px)'] },
{ duration: 100 * MS_PER_SEC,
easing: 'linear',
iterations: 10,
iterationComposite: 'accumulate' });
anim.pause();
anim.currentTime = anim.effect.getComputedTiming().duration / 2;
assert_matrix_equals(getComputedStyle(div).transform,
'matrix(0, 1, -1, 0, 0, 5)', // rotate(90deg) translateX(5px)
'Animated transform list at 50s of the first iteration');
anim.currentTime = anim.effect.getComputedTiming().duration * 2;
assert_matrix_equals(getComputedStyle(div).transform,
'matrix(1, 0, 0, 1, 20, 0)', // rotate(360deg) translateX(20px)
'Animated transform list at 0s of the third iteration');
anim.currentTime += anim.effect.getComputedTiming().duration / 2;
assert_matrix_equals(getComputedStyle(div).transform,
'matrix(0, 1, -1, 0, 0, 25)', // rotate(450deg) translateX(25px)
'Animated transform list at 50s of the third iteration');
}, 'iteration composition of transform list animation');
test(t => {
const div = createDiv(t);
const anim =
div.animate({ transform: ['matrix(2, 0, 0, 2, 0, 0)',
'matrix(3, 0, 0, 3, 30, 0)'] },
{ duration: 100 * MS_PER_SEC,
easing: 'linear',
iterations: 10,
iterationComposite: 'accumulate' });
anim.pause();
anim.currentTime = anim.effect.getComputedTiming().duration / 2;
assert_matrix_equals(getComputedStyle(div).transform,
'matrix(2.5, 0, 0, 2.5, 15, 0)',
'Animated transform of matrix function at 50s of the first iteration');
anim.currentTime = anim.effect.getComputedTiming().duration * 2;
assert_matrix_equals(getComputedStyle(div).transform,
// scale(2) + (scale(3-1)*2) + translateX(30px)*2
'matrix(6, 0, 0, 6, 60, 0)',
'Animated transform of matrix function at 0s of the third iteration');
anim.currentTime += anim.effect.getComputedTiming().duration / 2;
assert_matrix_equals(getComputedStyle(div).transform,
// from: matrix(6, 0, 0, 6, 60, 0)
// to: matrix(7, 0, 0, 7, 90, 0)
// = scale(3) + (scale(3-1)*2) + translateX(30px)*3
'matrix(6.5, 0, 0, 6.5, 75, 0)',
'Animated transform of matrix function at 50s of the third iteration');
}, 'iteration composition of transform of matrix function');
test(t => {
const div = createDiv(t);
const anim =
div.animate({ transform: ['translateX(0px) scale(2)',
'scale(3) translateX(10px)'] },
{ duration: 100 * MS_PER_SEC,
easing: 'linear',
iterations: 10,
iterationComposite: 'accumulate' });
anim.pause();
anim.currentTime = anim.effect.getComputedTiming().duration / 2;
assert_matrix_equals(getComputedStyle(div).transform,
// Interpolate between matrix(2, 0, 0, 2, 0, 0) = translateX(0px) scale(2)
// and matrix(3, 0, 0, 3, 30, 0) = scale(3) translateX(10px)
'matrix(2.5, 0, 0, 2.5, 15, 0)',
'Animated transform list at 50s of the first iteration');
anim.currentTime = anim.effect.getComputedTiming().duration * 2;
assert_matrix_equals(getComputedStyle(div).transform,
// 'from' and 'to' value are mismatched, so accumulate
// matrix(2, 0, 0, 2, 0, 0) onto matrix(3, 0, 0, 3, 30, 0) * 2
// = scale(2) + (scale(3-1)*2) + translateX(30px)*2
'matrix(6, 0, 0, 6, 60, 0)',
'Animated transform list at 0s of the third iteration');
anim.currentTime += anim.effect.getComputedTiming().duration / 2;
assert_matrix_equals(getComputedStyle(div).transform,
// Interpolate between matrix(6, 0, 0, 6, 60, 0)
// and matrix(7, 0, 0, 7, 210, 0) = scale(7) translate(30px)
'matrix(6.5, 0, 0, 6.5, 135, 0)',
'Animated transform list at 50s of the third iteration');
}, 'iteration composition of transform list animation whose order is'
+ ' mismatched');
test(t => {
const div = createDiv(t);
// Even if each transform list does not have functions which exist in
// other pair of the list, we don't fill any missing functions at all.
const anim =
div.animate({ transform: ['translateX(0px)',
'scale(2) translateX(10px)'] },
{ duration: 100 * MS_PER_SEC,
easing: 'linear',
iterations: 10,
iterationComposite: 'accumulate' });
anim.pause();
anim.currentTime = anim.effect.getComputedTiming().duration / 2;
assert_matrix_equals(getComputedStyle(div).transform,
// Interpolate between matrix(1, 0, 0, 1, 0, 0) = translateX(0px)
// and matrix(2, 0, 0, 2, 20, 0) = scale(2) translateX(10px)
'matrix(1.5, 0, 0, 1.5, 10, 0)',
'Animated transform list at 50s of the first iteration');
anim.currentTime = anim.effect.getComputedTiming().duration * 2;
assert_matrix_equals(getComputedStyle(div).transform,
// 'from' and 'to' value are mismatched, so accumulate
// matrix(1, 0, 0, 1, 0, 0) onto matrix(2, 0, 0, 2, 20, 0) * 2
// = scale(1) + (scale(2-1)*2) + translateX(20px)*2
'matrix(3, 0, 0, 3, 40, 0)',
'Animated transform list at 0s of the third iteration');
anim.currentTime += anim.effect.getComputedTiming().duration / 2;
assert_matrix_equals(getComputedStyle(div).transform,
// Interpolate between matrix(3, 0, 0, 3, 40, 0)
// and matrix(4, 0, 0, 4, 120, 0) =
// scale(2 + (2-1)*2) translate(10px * 3)
'matrix(3.5, 0, 0, 3.5, 80, 0)',
'Animated transform list at 50s of the third iteration');
}, 'iteration composition of transform list animation whose order is'
+ ' mismatched because of missing functions');
test(t => {
const div = createDiv(t);
const anim =
div.animate({ transform: ['none',
'translateX(10px)'] },
{ duration: 100 * MS_PER_SEC,
easing: 'linear',
iterations: 10,
iterationComposite: 'accumulate' });
anim.pause();
anim.currentTime = anim.effect.getComputedTiming().duration / 2;
assert_matrix_equals(getComputedStyle(div).transform,
// translateX(none) -> translateX(10px) @ 50%
'matrix(1, 0, 0, 1, 5, 0)',
'Animated transform list at 50s of the first iteration');
anim.currentTime = anim.effect.getComputedTiming().duration * 2;
assert_matrix_equals(getComputedStyle(div).transform,
// translateX(10px * 2 + none) -> translateX(10px * 2 + 10px) @ 0%
'matrix(1, 0, 0, 1, 20, 0)',
'Animated transform list at 0s of the third iteration');
anim.currentTime += anim.effect.getComputedTiming().duration / 2;
assert_matrix_equals(getComputedStyle(div).transform,
// translateX(10px * 2 + none) -> translateX(10px * 2 + 10px) @ 50%
'matrix(1, 0, 0, 1, 25, 0)',
'Animated transform list at 50s of the third iteration');
}, 'iteration composition of transform from none to translate');
test(t => {
const div = createDiv(t);
const anim =
div.animate({ transform: ['matrix3d(1, 0, 0, 0, ' +
'0, 1, 0, 0, ' +
'0, 0, 1, 0, ' +
'0, 0, 30, 1)',
'matrix3d(1, 0, 0, 0, ' +
'0, 1, 0, 0, ' +
'0, 0, 1, 0, ' +
'0, 0, 50, 1)'] },
{ duration: 100 * MS_PER_SEC,
easing: 'linear',
iterations: 10,
iterationComposite: 'accumulate' });
anim.pause();
anim.currentTime = anim.effect.getComputedTiming().duration / 2;
assert_matrix_equals(getComputedStyle(div).transform,
'matrix3d(1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 40, 1)',
'Animated transform of matrix3d function at 50s of the first iteration');
anim.currentTime = anim.effect.getComputedTiming().duration * 2;
assert_matrix_equals(getComputedStyle(div).transform,
// translateZ(30px) + (translateZ(50px)*2)
'matrix3d(1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 130, 1)',
'Animated transform of matrix3d function at 0s of the third iteration');
anim.currentTime += anim.effect.getComputedTiming().duration / 2;
assert_matrix_equals(getComputedStyle(div).transform,
// from: matrix3d(1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 130, 1)
// to: matrix3d(1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 150, 1)
'matrix3d(1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 140, 1)',
'Animated transform of matrix3d function at 50s of the third iteration');
}, 'iteration composition of transform of matrix3d function');
test(t => {
const div = createDiv(t);
const anim =
div.animate({ transform: ['rotate3d(1, 1, 0, 0deg)',
'rotate3d(1, 1, 0, 90deg)'] },
{ duration: 100 * MS_PER_SEC,
easing: 'linear',
iterations: 10,
iterationComposite: 'accumulate' });
anim.pause();
anim.currentTime = 0;
assert_matrix_equals(getComputedStyle(div).transform,
'matrix(1, 0, 0, 1, 0, 0)', // Actually not rotated at all.
'Animated transform of rotate3d function at 50s of the first iteration');
anim.currentTime = anim.effect.getComputedTiming().duration * 2;
assert_matrix_equals(getComputedStyle(div).transform,
rotate3dToMatrix3d(1, 1, 0, Math.PI), // 180deg
'Animated transform of rotate3d function at 0s of the third iteration');
anim.currentTime += anim.effect.getComputedTiming().duration / 2;
assert_matrix_equals(getComputedStyle(div).transform,
rotate3dToMatrix3d(1, 1, 0, 225 * Math.PI / 180), //((270 + 180) * 0.5)deg
'Animated transform of rotate3d function at 50s of the third iteration');
}, 'iteration composition of transform of rotate3d function');
test(t => {
const div = createDiv(t);
const anim =
div.animate({ marginLeft: ['10px', '20px'] },
{ duration: 100 * MS_PER_SEC,
easing: 'linear',
iterations: 10,
iterationComposite: 'accumulate' });
anim.pause();
anim.currentTime = anim.effect.getComputedTiming().duration / 2;
assert_equals(getComputedStyle(div).marginLeft, '15px',
'Animated margin-left style at 50s of the first iteration');
anim.currentTime = anim.effect.getComputedTiming().duration * 2;
assert_equals(getComputedStyle(div).marginLeft, '50px', // 10px + 20px + 20px
'Animated margin-left style at 0s of the third iteration');
anim.currentTime += anim.effect.getComputedTiming().duration / 2;
assert_equals(getComputedStyle(div).marginLeft, '55px', // (50px + 60px) * 0.5
'Animated margin-left style at 50s of the third iteration');
}, 'iteration composition starts with non-zero value animation');
test(t => {
const div = createDiv(t);
const anim =
div.animate({ marginLeft: ['10px', '-10px'] },
{ duration: 100 * MS_PER_SEC,
easing: 'linear',
iterations: 10,
iterationComposite: 'accumulate' });
anim.pause();
anim.currentTime = anim.effect.getComputedTiming().duration / 2;
assert_equals(getComputedStyle(div).marginLeft,
'0px',
'Animated margin-left style at 50s of the first iteration');
anim.currentTime = anim.effect.getComputedTiming().duration * 2;
assert_equals(getComputedStyle(div).marginLeft,
'-10px', // 10px + -10px + -10px
'Animated margin-left style at 0s of the third iteration');
anim.currentTime += anim.effect.getComputedTiming().duration / 2;
assert_equals(getComputedStyle(div).marginLeft,
'-20px', // (-10px + -30px) * 0.5
'Animated margin-left style at 50s of the third iteration');
}, 'iteration composition with negative final value animation');
test(t => {
const div = createDiv(t);
const anim = div.animate({ marginLeft: ['0px', '10px'] },
{ duration: 100 * MS_PER_SEC,
easing: 'linear',
iterations: 10,
iterationComposite: 'accumulate' });
anim.pause();
anim.currentTime =
anim.effect.getComputedTiming().duration * 2 +
anim.effect.getComputedTiming().duration / 2;
assert_equals(getComputedStyle(div).marginLeft, '25px',
'Animated style at 50s of the third iteration');
// double its duration.
anim.effect.updateTiming({
duration: anim.effect.getComputedTiming().duration * 2
});
assert_equals(getComputedStyle(div).marginLeft, '12.5px',
'Animated style at 25s of the first iteration');
// half of original.
anim.effect.updateTiming({
duration: anim.effect.getComputedTiming().duration / 4
});
assert_equals(getComputedStyle(div).marginLeft, '50px',
'Animated style at 50s of the fourth iteration');
}, 'duration changes with an iteration composition operation of accumulate');
</script>
|