tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

anchor-scroll-nested.html (1840B)


      1 <!DOCTYPE html>
      2 <html class="reftest-wait">
      3 <meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1">
      4 <title>Tests anchor positioning with nested scroll containers</title>
      5 <link rel="author" href="mailto:xiaochengh@chromium.org">
      6 <link rel="help" href="https://drafts.csswg.org/css-anchor-1/">
      7 <link rel="match" href="reference/anchor-scroll-nested-ref.html">
      8 <style>
      9 body {
     10  margin: 0;
     11  width: 1500px;
     12  height: 1500px;
     13  position: relative;
     14 }
     15 
     16 #outer-scroller {
     17  margin: 500px;
     18  width: 350px;
     19  height: 350px;
     20  outline: 1px solid black;
     21  overflow: scroll;
     22 }
     23 
     24 #inner-scroller {
     25  margin: 100px;
     26  width: 250px;
     27  height: 250px;
     28  outline: 1px solid black;
     29  overflow: scroll;
     30 }
     31 
     32 #anchor {
     33  margin: 200px;
     34  width: 50px;
     35  height: 50px;
     36  background-color: green;
     37  anchor-name: --anchor;
     38 }
     39 
     40 .anchored {
     41  position: absolute;
     42  width: 50px;
     43  height: 50px;
     44  left: anchor(left);
     45  position-anchor: --anchor;
     46 }
     47 
     48 .above {
     49  bottom: anchor(top);
     50  background-color: red;
     51 }
     52 
     53 .below {
     54  top: anchor(bottom);
     55  background-color: yellow;
     56 }
     57 </style>
     58 
     59 <div id="outer-scroller">
     60  <div id="inner-scroller">
     61    <div id="anchor"></div>
     62    <div class="anchored above"></div>
     63  </div>
     64 </div>
     65 
     66 <div class="anchored below"></div>
     67 
     68 <script>
     69 function raf() {
     70  return new Promise(resolve => requestAnimationFrame(resolve));
     71 }
     72 
     73 async function runTest() {
     74  await raf();
     75  await raf();
     76 
     77  document.documentElement.scrollTop = 400;
     78  document.documentElement.scrollLeft = 400;
     79 
     80  let outerScroller = document.getElementById('outer-scroller');
     81  outerScroller.scrollTop = 50;
     82  outerScroller.scrollLeft = 50;
     83 
     84  let innerScroller = document.getElementById('inner-scroller');
     85  innerScroller.scrollTop = 100;
     86  innerScroller.scrollLeft = 100;
     87 
     88  document.documentElement.classList.remove('reftest-wait');
     89 }
     90 runTest();
     91 </script>