transform-interpolation-004.html (8038B)
1 <!DOCTYPE html> 2 <meta charset="UTF-8"> 3 <title>transform interpolation</title> 4 <link rel="help" href="https://drafts.csswg.org/css-transforms/#transform-property"> 5 <meta name="assert" content="transform supports animation as a transform list"> 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 .target { 13 color: white; 14 width: 100px; 15 height: 100px; 16 background-color: black; 17 display: inline-block; 18 overflow: hidden; 19 } 20 .expected { 21 background-color: green; 22 } 23 .target > div { 24 width: 10px; 25 height: 10px; 26 display: inline-block; 27 background: orange; 28 margin: 1px; 29 } 30 .test { 31 overflow: hidden; 32 } 33 </style> 34 35 <body> 36 <template id="target-template"> 37 <div></div> 38 </template> 39 </body> 40 41 <script> 42 // Translate 43 test_interpolation({ 44 property: 'transform', 45 from: 'translate(12px, 70%)', 46 to: 'translate(13px, 90%)' 47 }, [ 48 {at: -1, expect: 'translate(11px, 50%)'}, 49 {at: 0, expect: 'translate(12px, 70%)'}, 50 {at: 0.25, expect: 'translate(12.25px, 75%)'}, 51 {at: 0.75, expect: 'translate(12.75px, 85%)'}, 52 {at: 1, expect: 'translate(13px, 90%)'}, 53 {at: 2, expect: 'translate(14px, 110%)'}, 54 ]); 55 test_interpolation({ 56 property: 'transform', 57 from: 'translateX(12px)', 58 to: 'translateX(13px)' 59 }, [ 60 {at: -1, expect: 'translateX(11px)'}, 61 {at: 0, expect: 'translateX(12px)'}, 62 {at: 0.25, expect: 'translateX(12.25px)'}, 63 {at: 0.75, expect: 'translateX(12.75px)'}, 64 {at: 1, expect: 'translateX(13px)'}, 65 {at: 2, expect: 'translateX(14px)'}, 66 ]); 67 test_interpolation({ 68 property: 'transform', 69 from: 'translateY(70%)', 70 to: 'translateY(90%)' 71 }, [ 72 {at: -1, expect: 'translateY(50%)'}, 73 {at: 0, expect: 'translateY(70%)'}, 74 {at: 0.25, expect: 'translateY(75%)'}, 75 {at: 0.75, expect: 'translateY(85%)'}, 76 {at: 1, expect: 'translateY(90%)'}, 77 {at: 2, expect: 'translateY(110%)'}, 78 ]); 79 test_interpolation({ 80 property: 'transform', 81 from: 'translateZ(2em)', 82 to: 'translateZ(3em)' 83 }, [ 84 {at: -1, expect: 'translateZ(1em)'}, 85 {at: 0, expect: 'translateZ(2em)'}, 86 {at: 0.25, expect: 'translateZ(2.25em)'}, 87 {at: 0.75, expect: 'translateZ(2.75em)'}, 88 {at: 1, expect: 'translateZ(3em)'}, 89 {at: 2, expect: 'translateZ(4em)'}, 90 ]); 91 test_interpolation({ 92 property: 'transform', 93 from: 'translate3d(12px, 70%, 2em)', 94 to: 'translate3d(13px, 90%, 3em)' 95 }, [ 96 {at: -1, expect: 'translate3d(11px, 50%, 1em)'}, 97 {at: 0, expect: 'translate3d(12px, 70%, 2em)'}, 98 {at: 0.25, expect: 'translate3d(12.25px, 75%, 2.25em)'}, 99 {at: 0.75, expect: 'translate3d(12.75px, 85%, 2.75em)'}, 100 {at: 1, expect: 'translate3d(13px, 90%, 3em)'}, 101 {at: 2, expect: 'translate3d(14px, 110%, 4em)'}, 102 ]); 103 test_interpolation({ 104 property: 'transform', 105 from: 'translateX(12px) translateY(70%) translateZ(2em)', 106 to: 'translateX(13px) translateY(90%) translateZ(3em)' 107 }, [ 108 {at: -1, expect: 'translateX(11px) translateY(50%) translateZ(1em)'}, 109 {at: 0, expect: 'translateX(12px) translateY(70%) translateZ(2em)'}, 110 {at: 0.25, expect: 'translateX(12.25px) translateY(75%) translateZ(2.25em)'}, 111 {at: 0.75, expect: 'translateX(12.75px) translateY(85%) translateZ(2.75em)'}, 112 {at: 1, expect: 'translateX(13px) translateY(90%) translateZ(3em)'}, 113 {at: 2, expect: 'translateX(14px) translateY(110%) translateZ(4em)'}, 114 ]); 115 test_interpolation({ 116 property: 'transform', 117 from: 'skewX(10rad) translateY(70%)', 118 to: 'skewX(20rad) translateY(90%)' 119 }, [ 120 {at: -1, expect: 'skewX(0rad) translateY(50%)'}, 121 {at: 0, expect: 'skewX(10rad) translateY(70%)'}, 122 {at: 0.25, expect: 'skewX(12.5rad) translateY(75%)'}, 123 {at: 0.75, expect: 'skewX(17.5rad) translateY(85%)'}, 124 {at: 1, expect: 'skewX(20rad) translateY(90%)'}, 125 {at: 2, expect: 'skewX(30rad) translateY(110%)'}, 126 ]); 127 test_interpolation({ 128 property: 'transform', 129 from: 'skewX(1rad)', 130 to: 'translate3d(8px, -4px, 12px) skewX(2rad)' 131 }, [ 132 {at: -1, expect: 'matrix3d(1, 0, 0, 0, 5.2998553125713235, 1, 0, 0, 0, 0, 1, 0, -8, 4, -12, 1)'}, 133 {at: 0, expect: 'matrix(1, 0, 1.5574077246549023, 1, 0, 0)'}, 134 {at: 0.25, expect: 'matrix3d(1, 0, 0, 0, 0.621795827675797, 1, 0, 0, 0, 0, 1, 0, 2, -1, 3, 1)'}, 135 {at: 0.75, expect: 'matrix3d(1, 0, 0, 0, -1.2494279662824135, 1, 0, 0, 0, 0, 1, 0, 6, -3, 9, 1)'}, 136 {at: 1, expect: 'matrix3d(1, 0, 0, 0, -2.185039863261519, 1, 0, 0, 0, 0, 1, 0, 8, -4, 12, 1)'}, 137 {at: 2, expect: 'matrix3d(1, 0, 0, 0, -5.9274874511779405, 1, 0, 0, 0, 0, 1, 0, 16, -8, 24, 1)'}, 138 ]); 139 test_interpolation({ 140 property: 'transform', 141 from: 'translate3d(8px, -4px, 12px) skewX(1rad) perspective(400px)', 142 to: 'scaleY(2) skewX(2rad) perspective(500px)' 143 }, [ 144 {at: -1, expect: 'matrix3d(1, 0, 0, 0, 0, 0, 0, 0, -0.03876288659793814, 0.01938144329896907, 0.94, -0.0029653608247422686, 16, -8, 24, 0.986144329896907)'}, 145 {at: 0, expect: 'matrix3d(1, 0, 0, 0, 1.5574077246549023, 1, 0, 0, -0.02, 0.01, 0.97, -0.0025, 8, -4, 12, 1)'}, 146 {at: 0.25, expect: 'matrix3d(1, 0, 0, 0, 1.1186572632293585, 1.25, 0, 0, -0.0151159793814433, 0.00755798969072165, 0.9775, -0.002378247422680413, 6, -3, 9, 1.0012989690721648)'}, 147 {at: 0.75, expect: 'matrix3d(1, 0, 0, 0, -0.7525665307288518, 1.75, 0, 0, -0.005115979381443298, 0.002557989690721649, 0.9924999999999999, -0.002128247422680412, 2, -1, 3, 1.001298969072165)'}, 148 {at: 1, expect: 'matrix3d(1, 0, 0, 0, -2.185039863261519, 2, 0, 0, 0, 0, 1, -0.002, 0, 0, 0, 1)'}, 149 {at: 2, expect: 'matrix3d(1, 0, 0, 0, -11.227342763749263, 3, 0, 0, 0.021237113402061854, -0.010618556701030927, 1.03, -0.0014653608247422677, -8, 4, -12, 0.9861443298969074)'}, 150 ]); 151 test_interpolation({ 152 property: 'transform', 153 from: 'translate3d(8px, -4px, 12px) skewX(1rad) perspective(400px)', 154 to: 'translate3d(4px, -12px, 8px) scaleY(2) perspective(500px)' 155 }, [ 156 {at: -1, expect: 'translate3d(12px, 4px, 16px) matrix3d(1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, -0.003, 0, 0, 0, 1)'}, 157 {at: 0, expect: 'translate3d(8px, -4px, 12px) matrix3d(1, 0, 0, 0, 1.55741, 1, 0, 0, 0, 0, 1, -0.0025, 0, 0, 0, 1)'}, 158 {at: 0.25, expect: 'translate3d(7px, -6px, 11px) matrix3d(1, 0, 0, 0, 1.46007, 1.25, 0, 0, 0, 0, 1, -0.002375, 0, 0, 0, 1)'}, 159 {at: 0.75, expect: 'translate3d(5px, -10px, 9px) matrix3d(1, 0, 0, 0, 0.681366, 1.75, 0, 0, 0, 0, 1, -0.002125, 0, 0, 0, 1)'}, 160 {at: 1, expect: 'translate3d(4px, -12px, 8px) matrix3d(1, 0, 0, 0, 0, 2, 0, 0, 0, 0, 1, -0.002, 0, 0, 0, 1)'}, 161 {at: 2, expect: 'translate3d(0px, -20px, 4px) matrix3d(1, 0, 0, 0, -4.67222, 3, 0, 0, 0, 0, 1, -0.0015, 0, 0, 0, 1)'}, 162 ]); 163 test_interpolation({ 164 property: 'transform', 165 from: 'translate3d(8px, -4px, 12px) skewX(1rad) perspective(400px)', 166 to: 'translate3d(4px, -12px, 8px) skewX(2rad) scaleY(2)' 167 }, [ 168 {at: -1, expect: 'translate3d(12px, 4px, 16px) skewX(0rad) matrix3d(1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, -0.005, 0, 0, 0, 1)'}, 169 {at: 0, expect: 'translate3d(8px, -4px, 12px) skewX(1rad) matrix3d(1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, -0.0025, 0, 0, 0, 1)'}, 170 {at: 0.25, expect: 'translate3d(7px, -6px, 11px) skewX(1.25rad) matrix3d(1, 0, 0, 0, 0, 1.25, 0, 0, 0, 0, 1, -0.001875, 0, 0, 0, 1)'}, 171 {at: 0.75, expect: 'translate3d(5px, -10px, 9px) skewX(1.75rad) matrix3d(1, 0, 0, 0, 0, 1.75, 0, 0, 0, 0, 1, -0.000625, 0, 0, 0, 1)'}, 172 {at: 1, expect: 'translate3d(4px, -12px, 8px) skewX(2rad) matrix(1, 0, 0, 2, 0, 0)'}, 173 {at: 2, expect: 'translate3d(0px, -20px, 4px) skewX(3rad) matrix3d(1, 0, 0, 0, 0, 3, 0, 0, 0, 0, 1, 0.0025, 0, 0, 0, 1)'}, 174 ]); 175 test_interpolation({ 176 property: 'transform', 177 from: 'translate3D(100px, 200px, 300px)', 178 to: 'none' 179 }, [ 180 {at: -1, expect: 'matrix3d(1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 200, 400, 600, 1)'}, 181 {at: 0, expect: 'matrix3d(1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 100, 200, 300, 1)'}, 182 {at: 0.25, expect: 'matrix3d(1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 75, 150, 225, 1)'}, 183 {at: 0.75, expect: 'matrix3d(1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 25, 50, 75, 1)'}, 184 {at: 1, expect: 'matrix(1, 0, 0, 1, 0, 0) '}, 185 {at: 2, expect: 'matrix3d(1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, -100, -200, -300, 1)'}, 186 ]); 187 </script>