DelaySign.js (1295B)
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 DelaySign 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 { delay, isDelayFilled, startTime } = animation.state.absoluteValues; 24 25 const toPercentage = v => (v / timeScale.getDuration()) * 100; 26 const offset = toPercentage(startTime - timeScale.minStartTime); 27 const width = toPercentage(Math.abs(delay)); 28 29 return dom.div({ 30 className: 31 "animation-delay-sign" + 32 (delay < 0 ? " negative" : "") + 33 (isDelayFilled ? " fill" : ""), 34 style: { 35 width: `${width}%`, 36 marginInlineStart: `${offset}%`, 37 }, 38 }); 39 } 40 } 41 42 module.exports = DelaySign;