source: trip-planner-front/node_modules/postcss-normalize-timing-functions/dist/index.js@ eed0bf8

Last change on this file since eed0bf8 was 6a3a178, checked in by Ema <ema_spirova@…>, 3 years ago

initial commit

  • Property mode set to 100644
File size: 2.8 KB
Line 
1"use strict";
2
3Object.defineProperty(exports, "__esModule", {
4 value: true
5});
6exports.default = void 0;
7
8var _postcssValueParser = _interopRequireDefault(require("postcss-value-parser"));
9
10var _cssnanoUtils = require("cssnano-utils");
11
12function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
13
14const getValue = node => parseFloat(node.value);
15
16function reduce(node) {
17 if (node.type !== 'function') {
18 return false;
19 }
20
21 if (!node.value) {
22 return;
23 }
24
25 const lowerCasedValue = node.value.toLowerCase();
26
27 if (lowerCasedValue === 'steps') {
28 // Don't bother checking the step-end case as it has the same length
29 // as steps(1)
30 if (node.nodes[0].type === 'word' && getValue(node.nodes[0]) === 1 && node.nodes[2] && node.nodes[2].type === 'word' && (node.nodes[2].value.toLowerCase() === 'start' || node.nodes[2].value.toLowerCase() === 'jump-start')) {
31 node.type = 'word';
32 node.value = 'step-start';
33 delete node.nodes;
34 return;
35 }
36
37 if (node.nodes[0].type === 'word' && getValue(node.nodes[0]) === 1 && node.nodes[2] && node.nodes[2].type === 'word' && (node.nodes[2].value.toLowerCase() === 'end' || node.nodes[2].value.toLowerCase() === 'jump-end')) {
38 node.type = 'word';
39 node.value = 'step-end';
40 delete node.nodes;
41 return;
42 } // The end case is actually the browser default, so it isn't required.
43
44
45 if (node.nodes[2] && node.nodes[2].type === 'word' && (node.nodes[2].value.toLowerCase() === 'end' || node.nodes[2].value.toLowerCase() === 'jump-end')) {
46 node.nodes = [node.nodes[0]];
47 return;
48 }
49
50 return false;
51 }
52
53 if (lowerCasedValue === 'cubic-bezier') {
54 const values = node.nodes.filter((list, index) => {
55 return index % 2 === 0;
56 }).map(getValue);
57
58 if (values.length !== 4) {
59 return;
60 }
61
62 const match = (0, _cssnanoUtils.getMatch)([['ease', [0.25, 0.1, 0.25, 1]], ['linear', [0, 0, 1, 1]], ['ease-in', [0.42, 0, 1, 1]], ['ease-out', [0, 0, 0.58, 1]], ['ease-in-out', [0.42, 0, 0.58, 1]]])(values);
63
64 if (match) {
65 node.type = 'word';
66 node.value = match;
67 delete node.nodes;
68 return;
69 }
70 }
71}
72
73function transform(value) {
74 return (0, _postcssValueParser.default)(value).walk(reduce).toString();
75}
76
77function pluginCreator() {
78 return {
79 postcssPlugin: 'postcss-normalize-timing-functions',
80
81 OnceExit(css) {
82 const cache = {};
83 css.walkDecls(/^(-\w+-)?(animation|transition)(-timing-function)?$/i, decl => {
84 const value = decl.value;
85
86 if (cache[value]) {
87 decl.value = cache[value];
88 return;
89 }
90
91 const result = transform(value);
92 decl.value = result;
93 cache[value] = result;
94 });
95 }
96
97 };
98}
99
100pluginCreator.postcss = true;
101var _default = pluginCreator;
102exports.default = _default;
103module.exports = exports.default;
Note: See TracBrowser for help on using the repository browser.