tor-browser

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

worklet-animation-with-scroll-timeline-and-overflow-hidden.https.html (1913B)


      1 <html class="reftest-wait">
      2 <title>Scroll timeline with WorkletAnimation using a scroller with overflow hidden</title>
      3 <link rel="help" href="https://drafts.css-houdini.org/css-animationworklet/">
      4 <meta name="assert" content="Worklet animation correctly updates values when using a overflow: hidden on the scroller being used as the source for the ScrollTimeline">
      5 <link rel="match" href="worklet-animation-with-scroll-timeline-and-overflow-hidden-ref.html">
      6 
      7 <script src="/web-animations/testcommon.js"></script>
      8 <script src="/common/reftest-wait.js"></script>
      9 <script src="common.js"></script>
     10 
     11 <style>
     12  #box {
     13    width: 100px;
     14    height: 100px;
     15    background-color: green;
     16  }
     17 
     18  #covered {
     19    width: 100px;
     20    height: 100px;
     21    background-color: red;
     22  }
     23 
     24  #scroller {
     25    overflow: hidden;
     26    height: 100px;
     27    width: 100px;
     28  }
     29 
     30  #contents {
     31    height: 1000px;
     32    width: 100%;
     33  }
     34 </style>
     35 
     36 <div id="box"></div>
     37 <div id="covered"></div>
     38 <div id="scroller">
     39  <div id="contents"></div>
     40 </div>
     41 
     42 <script>
     43  registerPassthroughAnimator().then(_ => {
     44    const box = document.getElementById('box');
     45    const effect = new KeyframeEffect(box,
     46      [
     47        {transform: 'translateY(0)', opacity: 1},
     48        {transform: 'translateY(200px)', opacity: 0}
     49      ], {
     50        duration: 1000,
     51      }
     52    );
     53 
     54    const scroller = document.getElementById('scroller');
     55    const timeline = new ScrollTimeline({ scrollSource: scroller, orientation: 'block' });
     56    const animation = new WorkletAnimation('passthrough', effect, timeline);
     57    animation.play();
     58 
     59    // Move the scroller to the halfway point.
     60    const maxScroll = scroller.scrollHeight - scroller.clientHeight;
     61    scroller.scrollTop = 0.5 * maxScroll;
     62    waitForAnimationFrameWithCondition(_ => {
     63      return getComputedStyle(box).transform != 'matrix(1, 0, 0, 1, 0, 0)';
     64    }).then(_ => {
     65      takeScreenshot();
     66    });
     67  });
     68 </script>