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 139 140
|
<!DOCTYPE html>
<html>
<title>View transitions: Dynamic stylesheet sets correct animations with proper timing function</title>
<link rel="help" href="https://drafts.csswg.org/css-view-transitions/#setup-transition-pseudo-elements-algorithm">
<link rel="help" href="https://drafts.csswg.org/css-animations-1/">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="/web-animations/testcommon.js"></script>
<style>
body { margin: 0; }
:root { view-transition-name: none; }
html::view-transition-group(*),
html::view-transition-old(*),
html::view-transition-new(*) {
animation-duration: 10s;
animation-delay: -5s;
animation-play-state: paused;
}
#target { view-transition-name: target; }
.init {
width: 100px;
height: 100px;
}
.large {
width: 300px;
height: 300px;
}
.left {
margin-left: 100px;
}
.right {
margin-left: 300px;
}
/* For generating the transform with ease, as reference */
@keyframes anim {
from { transform: translate(100px); }
to { transform: translate(300px); }
}
</style>
<div id="target"></div>
<script>
promise_test(async t => {
const ref = createDiv(t);
ref.style.animation = "anim 10s -5s paused ease";
target.classList.add("init", "left");
const vt = document.startViewTransition(() => {
target.classList.remove("left");
target.classList.add("right");
});
await vt.ready;
assert_equals(
getComputedStyle(document.documentElement,
"::view-transition-group(target)").animationTimingFunction,
"ease",
"The default timing function"
);
assert_equals(
getComputedStyle(document.documentElement,
"::view-transition-group(target)").transform,
getComputedStyle(ref).transform,
"transform with ease at 50%"
);
await vt.skipTransition();
target.className = "";
}, "The transform property with ease on ::view-transition-group()");
promise_test(async t => {
document.styleSheets[0].insertRule(
"::view-transition-group(target) { animation-timing-function: linear; }",
document.styleSheets[0].cssRules.length
);
t.add_cleanup(() => {
document.styleSheets[0].deleteRule(
document.styleSheets[0].cssRules.length - 1
);
});
target.classList.add("init");
let vt = document.startViewTransition(() => {
target.classList.remove("init");
target.classList.add("large");
});
await vt.ready;
assert_equals(
getComputedStyle(document.documentElement,
"::view-transition-group(target)").width,
"200px",
"width at 50%"
);
assert_equals(
getComputedStyle(document.documentElement,
"::view-transition-group(target)").height,
"200px",
"height at 50%"
);
await vt.skipTransition();
target.className = "";
}, "The sizing properties with linear on ::view-transition-group()");
promise_test(async t => {
target.classList.add("init", "left");
let vt = document.startViewTransition(() => {
target.classList.remove("left");
target.classList.add("right");
});
await vt.ready;
document.styleSheets[0].insertRule(
"::view-transition-group(target) { animation-timing-function: linear; }",
document.styleSheets[0].cssRules.length
);
t.add_cleanup(() => {
document.styleSheets[0].deleteRule(
document.styleSheets[0].cssRules.length - 1
);
});
assert_equals(
getComputedStyle(document.documentElement,
"::view-transition-group(target)").transform,
"matrix(1, 0, 0, 1, 200, 0)",
"transform at 50% with linear"
);
await vt.skipTransition();
target.className = "";
}, "Changing the timing function of ::view-transition-group() when animating");
</script>
</body>
</html>
|