这是可行的,但持续时间设置被忽略了。我遗漏了什么?
https://jsfiddle.net/r76z0o8s/
function onClick(e) {
e.target.classList.add('clicked_media_transition')
document.startViewTransition(() => {
e.target.classList.add('expand')
})
}
body {
margin: 0;
}
div {
width: 300px;
height: 300px;
background-color: pink;
position: absolute;
}
.expand {
width: 100vw;
height: 100vh;
top: 0;
left: 0;
}
::view-transition-group(clicked_media_transition) {
transition-duration: 5s;
transition-timing-function: ease-out;
}
.clicked_media_transition {
view-transition-name: clicked_media_transition;
}
<div onclick="onClick(event)"></div>