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
|
<!DOCTYPE html>
<meta charset="UTF-8">
<title>clip interpolation</title>
<link rel="help" href="https://drafts.fxtf.org/css-masking-1/#clip-property">
<meta name="assert" content="clip supports animation">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="/css/support/interpolation-testcommon.js"></script>
<style>
.container {
width: 80px;
height: 80px;
background: black;
display: inline-block;
padding: 5px;
}
.container:nth-child(2n) {
background: green;
}
.parent {
clip: rect(100px, 0px, 100px, 0px);
}
.target {
width: 80px;
height: 80px;
display: inline-block;
position: absolute;
background: white;
clip: rect(0px, 100px, 0px, 100px);
}
</style>
<body>
<template id="target-template">
<div class="container"><div class="target"></div></div>
</template>
<script>
test_interpolation({
property: 'clip',
from: neutralKeyframe,
to: 'rect(20px, 20px, 20px, 20px)',
}, [
{at: -1, expect: 'rect(-20px 180px -20px 180px)'},
{at: 0, expect: 'rect(0px 100px 0px 100px)'},
{at: 0.25, expect: 'rect(5px 80px 5px 80px)'},
{at: 0.75, expect: 'rect(15px 40px 15px 40px)'},
{at: 1, expect: 'rect(20px 20px 20px 20px)'},
{at: 2, expect: 'rect(40px -60px 40px -60px)'},
]);
test_no_interpolation({
property: 'clip',
from: 'initial',
to: 'rect(20px, 20px, 20px, 20px)',
});
test_interpolation({
property: 'clip',
from: 'inherit',
to: 'rect(20px, 20px, 20px, 20px)',
}, [
{at: -1, expect: 'rect(180px -20px 180px -20px)'},
{at: 0, expect: 'rect(100px 0px 100px 0px)'},
{at: 0.25, expect: 'rect(80px 5px 80px 5px)'},
{at: 0.75, expect: 'rect(40px 15px 40px 15px)'},
{at: 1, expect: 'rect(20px 20px 20px 20px)'},
{at: 2, expect: 'rect(-60px 40px -60px 40px)'},
]);
test_no_interpolation({
property: 'clip',
from: 'unset',
to: 'rect(20px, 20px, 20px, 20px)',
});
test_interpolation({
property: 'clip',
from: 'rect(0px, 75px, 80px, 10px)',
to: 'rect(0px, 100px, 90px, 5px)'
}, [
{at: -1, expect: 'rect(0px, 50px, 70px, 15px)'},
{at: 0, expect: 'rect(0px, 75px, 80px, 10px)'},
{at: 0.25, expect: 'rect(0px, 81.25px, 82.5px, 8.75px)'},
{at: 0.75, expect: 'rect(0px, 93.75px, 87.5px, 6.25px)'},
{at: 1, expect: 'rect(0px, 100px, 90px, 5px)'},
{at: 2, expect: 'rect(0px, 125px, 100px, 0px)'},
]);
test_no_interpolation({
property: 'clip',
from: 'rect(auto, auto, auto, 10px)',
to: 'rect(20px, 50px, 50px, auto)'
});
test_no_interpolation({
property: 'clip',
from: 'rect(auto, 0px, auto, 10px)',
to: 'rect(auto, 50px, 50px, auto)'
});
test_no_interpolation({
property: 'clip',
from: 'auto',
to: 'rect(0px, 50px, 50px, 0px)'
});
test_no_interpolation({
property: 'clip',
from: 'rect(0px, 50px, 50px, 0px)',
to: 'auto'
});
</script>
|