1 | "use strict";
|
2 |
|
3 | exports.__esModule = true;
|
4 | exports["default"] = between;
|
5 | var _getValueAndUnit5 = _interopRequireDefault(require("../helpers/getValueAndUnit"));
|
6 | var _errors = _interopRequireDefault(require("../internalHelpers/_errors"));
|
7 | function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
8 |
|
9 |
|
10 |
|
11 |
|
12 |
|
13 |
|
14 |
|
15 |
|
16 |
|
17 |
|
18 |
|
19 |
|
20 |
|
21 |
|
22 |
|
23 |
|
24 |
|
25 |
|
26 |
|
27 |
|
28 |
|
29 |
|
30 |
|
31 | function between(fromSize, toSize, minScreen, maxScreen) {
|
32 | if (minScreen === void 0) {
|
33 | minScreen = '320px';
|
34 | }
|
35 | if (maxScreen === void 0) {
|
36 | maxScreen = '1200px';
|
37 | }
|
38 | var _getValueAndUnit = (0, _getValueAndUnit5["default"])(fromSize),
|
39 | unitlessFromSize = _getValueAndUnit[0],
|
40 | fromSizeUnit = _getValueAndUnit[1];
|
41 | var _getValueAndUnit2 = (0, _getValueAndUnit5["default"])(toSize),
|
42 | unitlessToSize = _getValueAndUnit2[0],
|
43 | toSizeUnit = _getValueAndUnit2[1];
|
44 | var _getValueAndUnit3 = (0, _getValueAndUnit5["default"])(minScreen),
|
45 | unitlessMinScreen = _getValueAndUnit3[0],
|
46 | minScreenUnit = _getValueAndUnit3[1];
|
47 | var _getValueAndUnit4 = (0, _getValueAndUnit5["default"])(maxScreen),
|
48 | unitlessMaxScreen = _getValueAndUnit4[0],
|
49 | maxScreenUnit = _getValueAndUnit4[1];
|
50 | if (typeof unitlessMinScreen !== 'number' || typeof unitlessMaxScreen !== 'number' || !minScreenUnit || !maxScreenUnit || minScreenUnit !== maxScreenUnit) {
|
51 | throw new _errors["default"](47);
|
52 | }
|
53 | if (typeof unitlessFromSize !== 'number' || typeof unitlessToSize !== 'number' || fromSizeUnit !== toSizeUnit) {
|
54 | throw new _errors["default"](48);
|
55 | }
|
56 | if (fromSizeUnit !== minScreenUnit || toSizeUnit !== maxScreenUnit) {
|
57 | throw new _errors["default"](76);
|
58 | }
|
59 | var slope = (unitlessFromSize - unitlessToSize) / (unitlessMinScreen - unitlessMaxScreen);
|
60 | var base = unitlessToSize - slope * unitlessMaxScreen;
|
61 | return "calc(" + base.toFixed(2) + (fromSizeUnit || '') + " + " + (100 * slope).toFixed(2) + "vw)";
|
62 | }
|
63 | module.exports = exports.default; |
\ | No newline at end of file |