composited-transform.html (1351B)
1 <!DOCTYPE html> 2 <meta charset="utf-8"> 3 <title>Composition of transform animations</title> 4 <link rel="help" href="https://drafts.csswg.org/css-transforms-2/#combining-transform-lists"> 5 <meta name="assert" content="transform animations should composite correctly"> 6 <script src="/resources/testharness.js"></script> 7 <script src="/resources/testharnessreport.js"></script> 8 9 <div id="target"><div> 10 11 <script> 12 test(() => { 13 var anim1 = target.animate( 14 { transform: [ 'translateX(0)', 'translateX(100px)' ]}, 15 1000 16 ); 17 var anim2 = target.animate( 18 { transform: [ 'translateY(0)', 'translateY(100px)' ]}, 19 {duration: 1000, composite: 'add'} 20 ); 21 22 anim1.pause(); 23 anim2.pause(); 24 25 anim1.currentTime = 200; 26 anim2.currentTime = 800; 27 28 // The computation here should be: 29 // underlying_value = 'translateX(0)' --> 'translateX(100px)' @ 0.2 30 // = 'translateX(20px)' 31 // final_value = 0.2 * ('translateX(20px) translateY(0)') + 32 // 0.8 * ('translateX(20px) translateY(100px)') 33 // = 'translateX(20px) translateY(80px)' 34 // = 'matrix(1, 0, 0, 1, 20, 80)' 35 assert_equals(getComputedStyle(target).transform, 'matrix(1, 0, 0, 1, 20, 80)') 36 }, 'An additive transform animation on-top of a replace transform animation ' + 37 'should composite correctly'); 38 </script>