<!DOCTYPE html> | |
<meta charset="UTF-8"> | |
<style> | |
.parent { | |
opacity: 0.8; | |
} | |
.target { | |
width: 100px; | |
height: 100px; | |
background-color: black; | |
display: inline-block; | |
opacity: 0.1; | |
} | |
.expected { | |
background-color: green; | |
} | |
</style> | |
<body> | |
<script src="resources/interpolation-test.js"></script> | |
<script> | |
assertInterpolation({ | |
property: 'opacity', | |
from: neutralKeyframe, | |
to: '0.2', | |
}, [ | |
{at: -0.3, is: '0.07'}, | |
{at: 0, is: '0.1'}, | |
{at: 0.3, is: '0.13'}, | |
{at: 0.6, is: '0.16'}, | |
{at: 1, is: '0.2'}, | |
{at: 1.5, is: '0.25'}, | |
]); | |
assertInterpolation({ | |
property: 'opacity', | |
from: 'initial', | |
to: '0.2', | |
}, [ | |
{at: -0.3, is: '1'}, | |
{at: 0, is: '1'}, | |
{at: 0.3, is: '0.76'}, | |
{at: 0.6, is: '0.52'}, | |
{at: 1, is: '0.2'}, | |
{at: 1.5, is: '0'}, | |
]); | |
assertInterpolation({ | |
property: 'opacity', | |
from: 'inherit', | |
to: '0.2', | |
}, [ | |
{at: -0.3, is: '0.98'}, | |
{at: 0, is: '0.8'}, | |
{at: 0.3, is: '0.62'}, | |
{at: 0.6, is: '0.44'}, | |
{at: 1, is: '0.2'}, | |
{at: 1.5, is: '0'}, | |
]); | |
assertInterpolation({ | |
property: 'opacity', | |
from: 'unset', | |
to: '0.2', | |
}, [ | |
{at: -0.3, is: '1'}, | |
{at: 0, is: '1'}, | |
{at: 0.3, is: '0.76'}, | |
{at: 0.6, is: '0.52'}, | |
{at: 1, is: '0.2'}, | |
{at: 1.5, is: '0'}, | |
]); | |
assertInterpolation({ | |
property: 'opacity', | |
from: '0', | |
to: '1' | |
}, [ | |
{at: -0.3, is: '0'}, // CSS opacity is [0-1]. | |
{at: 0, is: '0'}, | |
{at: 0.3, is: '0.3'}, | |
{at: 0.6, is: '0.6'}, | |
{at: 1, is: '1'}, | |
{at: 1.5, is: '1'} | |
]); | |
</script> | |
</body> |