| <!DOCTYPE html> |
| <meta charset="UTF-8"> |
| <style> |
| .parent { |
| margin: 10px; |
| border: solid; |
| display: inline-block; |
| } |
| .target { |
| width: 40px; |
| height: 40px; |
| background-color: black; |
| display: inline-block; |
| margin: 30px; |
| opacity: 0.5; |
| } |
| .expected { |
| background-color: green; |
| } |
| </style> |
| <body> |
| <template id="target-template"> |
| <div> |
| <div class="target"></div> |
| </div> |
| </template> |
| <script src="resources/interpolation-test.js"></script> |
| <script> |
| assertInterpolation({ |
| property: 'margin', |
| from: neutralKeyframe, |
| to: '20px', |
| }, [ |
| {at: -0.3, is: '33px'}, |
| {at: 0, is: '30px'}, |
| {at: 0.3, is: '27px'}, |
| {at: 0.6, is: '24px'}, |
| {at: 1, is: '20px'}, |
| {at: 1.5, is: '15px'}, |
| ]); |
| |
| assertInterpolation({ |
| property: 'margin', |
| from: 'initial', |
| to: '20px', |
| }, [ |
| {at: -0.3, is: '-6px'}, |
| {at: 0, is: '0px'}, |
| {at: 0.3, is: '6px'}, |
| {at: 0.6, is: '12px'}, |
| {at: 1, is: '20px'}, |
| {at: 1.5, is: '30px'}, |
| ]); |
| |
| assertInterpolation({ |
| property: 'margin', |
| from: 'inherit', |
| to: '20px', |
| }, [ |
| {at: -0.3, is: '7px'}, |
| {at: 0, is: '10px'}, |
| {at: 0.3, is: '13px'}, |
| {at: 0.6, is: '16px'}, |
| {at: 1, is: '20px'}, |
| {at: 1.5, is: '25px'}, |
| ]); |
| |
| assertInterpolation({ |
| property: 'margin', |
| from: 'unset', |
| to: '20px', |
| }, [ |
| {at: -0.3, is: '-6px'}, |
| {at: 0, is: '0px'}, |
| {at: 0.3, is: '6px'}, |
| {at: 0.6, is: '12px'}, |
| {at: 1, is: '20px'}, |
| {at: 1.5, is: '30px'}, |
| ]); |
| |
| assertInterpolation({ |
| property: 'margin', |
| from: '0px', |
| to: '10px' |
| }, [ |
| {at: -0.3, is: '-3px'}, |
| {at: 0, is: '0px'}, |
| {at: 0.3, is: '3px'}, |
| {at: 0.6, is: '6px'}, |
| {at: 1, is: '10px'}, |
| {at: 1.5, is: '15px'} |
| ]); |
| |
| assertInterpolation({ |
| property: 'margin', |
| from: '20px 40px 60px 80px', |
| to: '30px 50px 70px 90px' |
| }, [ |
| {at: -0.3, is: '17px 37px 57px 77px'}, |
| {at: 0, is: '20px 40px 60px 80px'}, |
| {at: 0.3, is: '23px 43px 63px 83px'}, |
| {at: 0.6, is: '26px 46px 66px 86px'}, |
| {at: 1, is: '30px 50px 70px 90px'}, |
| {at: 1.5, is: '35px 55px 75px 95px'} |
| ]); |
| </script> |
| </body> |