1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138
|
<!DOCTYPE html>
<meta charset="UTF-8">
<title>width interpolation with interpolate-size: allow-keywords</title>
<link rel="help" href="https://drafts.csswg.org/css-sizing-3/#propdef-width">
<link rel="help" href="https://drafts.csswg.org/css-values-5/#interpolate-size">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="/css/support/interpolation-testcommon.js"></script>
<style>
:root {
interpolate-size: allow-keywords;
}
.parent {
width: 150px;
overflow: visible;
}
.target {
width: 50px;
height: 10px;
}
.target::before {
display: block;
content: "";
width: 100px;
height: 50px;
}
</style>
<body>
<template id="target-template">
<div class="container">
<div class="target"></div>
</div>
</template>
</body>
<script>
test_interpolation({
property: 'width',
from: 'initial', /* 150px */
to: '50px',
}, [
{at: -0.3, expect: '180px'},
{at: 0, expect: '150px'},
{at: 0.3, expect: '120px'},
{at: 0.6, expect: '90px'},
{at: 1, expect: '50px'},
{at: 1.5, expect: '0px'}
]);
test_interpolation({
property: 'width',
from: 'unset', /* 150px */
to: '50px',
}, [
{at: -0.3, expect: '180px'},
{at: 0, expect: '150px'},
{at: 0.3, expect: '120px'},
{at: 0.6, expect: '90px'},
{at: 1, expect: '50px'},
{at: 1.5, expect: '0px'}
]);
test_interpolation({
property: 'width',
from: 'auto', /* 150px */
to: '50px',
}, [
{at: -0.3, expect: '180px'},
{at: 0, expect: '150px'},
{at: 0.3, expect: '120px'},
{at: 0.6, expect: '90px'},
{at: 1, expect: '50px'},
{at: 1.5, expect: '0px'}
]);
test_no_interpolation({
property: 'width',
from: 'auto',
to: 'fit-content',
});
test_no_interpolation({
property: 'width',
from: 'stretch',
to: 'auto',
});
test_interpolation({
property: 'width',
from: '200px',
to: 'fit-content', /* 100px */
}, [
{at: -0.3, expect: '230px'},
{at: 0, expect: '200px'},
{at: 0.3, expect: '170px'},
{at: 0.6, expect: '140px'},
{at: 1, expect: '100px'},
{at: 1.5, expect: '50px'}
]);
test_no_interpolation({
property: 'width',
from: 'max-content',
to: 'min-content',
});
test_interpolation({
property: 'width',
from: 'max-content', /* 100px */
to: neutralKeyframe, /* 50px */
}, [
{at: -0.3, expect: '115px'},
{at: 0, expect: '100px'},
{at: 0.3, expect: '85px'},
{at: 0.6, expect: '70px'},
{at: 1, expect: '50px'},
{at: 1.5, expect: '25px'}
]);
test_interpolation({
property: 'width',
from: neutralKeyframe, /* 50px */
to: 'min-content', /* 100px */
}, [
{at: -0.3, expect: '35px'},
{at: 0, expect: '50px'},
{at: 0.3, expect: '65px'},
{at: 0.6, expect: '80px'},
{at: 1, expect: '100px'},
{at: 1.5, expect: '125px'}
]);
</script>
</body>
|