tor-browser

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

EndDelaySign.js (1373B)


      1 /* This Source Code Form is subject to the terms of the Mozilla Public
      2 * License, v. 2.0. If a copy of the MPL was not distributed with this
      3 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
      4 
      5 "use strict";
      6 
      7 const {
      8  PureComponent,
      9 } = require("resource://devtools/client/shared/vendor/react.mjs");
     10 const dom = require("resource://devtools/client/shared/vendor/react-dom-factories.js");
     11 const PropTypes = require("resource://devtools/client/shared/vendor/react-prop-types.mjs");
     12 
     13 class EndDelaySign extends PureComponent {
     14  static get propTypes() {
     15    return {
     16      animation: PropTypes.object.isRequired,
     17      timeScale: PropTypes.object.isRequired,
     18    };
     19  }
     20 
     21  render() {
     22    const { animation, timeScale } = this.props;
     23    const { endDelay, endTime, isEndDelayFilled } =
     24      animation.state.absoluteValues;
     25 
     26    const toPercentage = v => (v / timeScale.getDuration()) * 100;
     27    const absEndDelay = Math.abs(endDelay);
     28    const offset = toPercentage(endTime - absEndDelay - timeScale.minStartTime);
     29    const width = toPercentage(absEndDelay);
     30 
     31    return dom.div({
     32      className:
     33        "animation-end-delay-sign" +
     34        (endDelay < 0 ? " negative" : "") +
     35        (isEndDelayFilled ? " fill" : ""),
     36      style: {
     37        width: `${width}%`,
     38        marginInlineStart: `${offset}%`,
     39      },
     40    });
     41  }
     42 }
     43 
     44 module.exports = EndDelaySign;