margin-interpolation.html (2415B)
1 <!DOCTYPE html> 2 <meta charset="UTF-8"> 3 <title>margin interpolation</title> 4 <link rel="help" href="https://www.w3.org/TR/CSS2/box.html#margin-properties"> 5 <meta name="assert" content="margin supports animation"> 6 7 <script src="/resources/testharness.js"></script> 8 <script src="/resources/testharnessreport.js"></script> 9 <script src="/css/support/interpolation-testcommon.js"></script> 10 11 <style> 12 .parent { 13 margin: 10px; 14 border: solid; 15 display: inline-block; 16 } 17 18 .target { 19 width: 40px; 20 height: 40px; 21 background-color: black; 22 display: inline-block; 23 margin: 30px; 24 opacity: 0.5; 25 } 26 27 .expected { 28 background-color: green; 29 } 30 </style> 31 32 <body> 33 <template id="target-template"> 34 <div> 35 <div class="target"></div> 36 </div> 37 </template> 38 39 <script> 40 test_interpolation({ 41 property: 'margin', 42 from: neutralKeyframe, 43 to: '20px', 44 }, [ 45 {at: -0.3, expect: '33px'}, 46 {at: 0, expect: '30px'}, 47 {at: 0.3, expect: '27px'}, 48 {at: 0.6, expect: '24px'}, 49 {at: 1, expect: '20px'}, 50 {at: 1.5, expect: '15px'}, 51 ]); 52 53 test_interpolation({ 54 property: 'margin', 55 from: 'initial', 56 to: '20px', 57 }, [ 58 {at: -0.3, expect: '-6px'}, 59 {at: 0, expect: '0px'}, 60 {at: 0.3, expect: '6px'}, 61 {at: 0.6, expect: '12px'}, 62 {at: 1, expect: '20px'}, 63 {at: 1.5, expect: '30px'}, 64 ]); 65 66 test_interpolation({ 67 property: 'margin', 68 from: 'inherit', 69 to: '20px', 70 }, [ 71 {at: -0.3, expect: '7px'}, 72 {at: 0, expect: '10px'}, 73 {at: 0.3, expect: '13px'}, 74 {at: 0.6, expect: '16px'}, 75 {at: 1, expect: '20px'}, 76 {at: 1.5, expect: '25px'}, 77 ]); 78 79 test_interpolation({ 80 property: 'margin', 81 from: 'unset', 82 to: '20px', 83 }, [ 84 {at: -0.3, expect: '-6px'}, 85 {at: 0, expect: '0px'}, 86 {at: 0.3, expect: '6px'}, 87 {at: 0.6, expect: '12px'}, 88 {at: 1, expect: '20px'}, 89 {at: 1.5, expect: '30px'}, 90 ]); 91 92 test_interpolation({ 93 property: 'margin', 94 from: '0px', 95 to: '10px' 96 }, [ 97 {at: -0.3, expect: '-3px'}, 98 {at: 0, expect: '0px'}, 99 {at: 0.3, expect: '3px'}, 100 {at: 0.6, expect: '6px'}, 101 {at: 1, expect: '10px'}, 102 {at: 1.5, expect: '15px'} 103 ]); 104 105 test_interpolation({ 106 property: 'margin', 107 from: '20px 40px 60px 80px', 108 to: '30px 50px 70px 90px' 109 }, [ 110 {at: -0.3, expect: '17px 37px 57px 77px'}, 111 {at: 0, expect: '20px 40px 60px 80px'}, 112 {at: 0.3, expect: '23px 43px 63px 83px'}, 113 {at: 0.6, expect: '26px 46px 66px 86px'}, 114 {at: 1, expect: '30px 50px 70px 90px'}, 115 {at: 1.5, expect: '35px 55px 75px 95px'} 116 ]); 117 </script> 118 </body>