new-content-intrinsic-aspect-ratio.html (1830B)
1 <!DOCTYPE html> 2 <html class=reftest-wait> 3 <title>View transitions: different width container should keep aspect ratio (by default)</title> 4 <link rel="help" href="https://drafts.csswg.org/css-view-transitions-1/"> 5 <link rel="author" href="mailto:vmpstr@chromium.org"> 6 <link rel="match" href="intrinsic-aspect-ratio-ref.html"> 7 <script src="/common/reftest-wait.js"></script> 8 <style> 9 .spacer { 10 height: 10px; 11 } 12 .box { 13 width: 100px; 14 height: 100px; 15 contain: paint; 16 background: blue; 17 } 18 #target1 { 19 view-transition-name: target1; 20 } 21 #target2 { 22 view-transition-name: target2; 23 } 24 #hidden { 25 view-transition-name: hidden; 26 width: 10px; 27 height: 10px; 28 visibility: hidden; 29 contain: paint; 30 } 31 32 /* We're verifying what we capture, so just display the new contents for 5 minutes. */ 33 html::view-transition-group(*) { animation-duration: 300s; } 34 html::view-transition-new(*) { animation: unset; opacity: 1; } 35 html::view-transition-old(*) { animation: unset; opacity: 0; } 36 37 html::view-transition-group(target1) { 38 animation: unset; 39 width: 50px; 40 border: 2px solid black; 41 } 42 html::view-transition-group(target2) { 43 animation: unset; 44 width: 200px; 45 border: 2px solid black; 46 } 47 48 /* hide the root so we show transition background to ensure we're in a transition */ 49 html::view-transition-group(root) { animation: unset; opacity: 0; } 50 html::view-transition { background: lightpink; } 51 </style> 52 53 <div id=target1 class=box></div> 54 <div class=spacer></div> 55 <div id=target2 class=box></div> 56 <div id=hidden></div> 57 <script> 58 failIfNot(document.startViewTransition, "Missing document.startViewTransition"); 59 60 async function runTest() { 61 document.startViewTransition(() => { 62 requestAnimationFrame(() => requestAnimationFrame(takeScreenshot)); 63 }); 64 } 65 onload = () => requestAnimationFrame(() => requestAnimationFrame(runTest)); 66 </script>