
Add configuration parameters for specifying the duration for an animation and delay from the universal timeline when the transition starts. These values apply at the level of a transition unit : single element, paired elements or root transition. The value directly applies to the transform/size animation but opacity is decided by the browser as a proportion of this duration. R=vmpstr@chromium.org Bug: 1246508 Change-Id: I60d88977b660fe6fd1f00ca1d646baa766ba2bd0 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3142050 Auto-Submit: Khushal <khushalsagar@chromium.org> Reviewed-by: vmpstr <vmpstr@chromium.org> Reviewed-by: Tom Sepez <tsepez@chromium.org> Commit-Queue: vmpstr <vmpstr@chromium.org> Cr-Commit-Position: refs/heads/main@{#919600}
70 lines
1.4 KiB
HTML
70 lines
1.4 KiB
HTML
<!DOCTYPE html>
|
|
<html>
|
|
<title>Shared transitions of different elements and shapes</title>
|
|
<link rel="help" href="https://github.com/vmpstr/shared-element-transitions">
|
|
<link rel="author" href="mailto:vmpstr@chromium.org">
|
|
|
|
<style>
|
|
body {
|
|
background: lightpink;
|
|
overflow: hidden;
|
|
}
|
|
|
|
input {
|
|
position: absolute;
|
|
left: 8px;
|
|
top: 8px;
|
|
z-index: 10;
|
|
}
|
|
|
|
.top {
|
|
top: 0px;
|
|
}
|
|
.bottom {
|
|
bottom: 0px;
|
|
}
|
|
|
|
div {
|
|
position: absolute;
|
|
left: 0px;
|
|
right: 0px;
|
|
height: 40vh;
|
|
background: green;
|
|
contain: paint;
|
|
}
|
|
</style>
|
|
|
|
<input id=toggle type=button value="Toggle!"></input>
|
|
<div id=target class=top>
|
|
The green div should alternate being at the bottom and at the top.
|
|
Other than green and pink background no other colors should appear.
|
|
</div>
|
|
|
|
<script>
|
|
let classes = ["top", "bottom"]
|
|
let backgroundColors = ["lightpink", "lightblue"]
|
|
let i = 0;
|
|
async function runAnimation() {
|
|
await document.documentTransition.prepare({
|
|
rootTransition: "explode",
|
|
rootConfig: {duration:"500", delay: "500"},
|
|
sharedElements: [target],
|
|
sharedElementsConfig: [{duration:"1000", delay:"1000"}]
|
|
});
|
|
|
|
document.body.style.background = backgroundColors[i];
|
|
target.classList.remove(classes[i]);
|
|
i = (i + 1) % classes.length;
|
|
target.classList.add(classes[i]);
|
|
|
|
await document.documentTransition.start({
|
|
sharedElements: [target]
|
|
});
|
|
}
|
|
|
|
function init() {
|
|
toggle.addEventListener("click", runAnimation);
|
|
}
|
|
onload = init;
|
|
</script>
|