source: trip-planner-front/node_modules/postcss-ordered-values/dist/rules/transition.js@ bdd6491

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

initial commit

  • Property mode set to 100644
File size: 1.9 KB
Line 
1"use strict";
2
3Object.defineProperty(exports, "__esModule", {
4 value: true
5});
6exports.default = normalizeTransition;
7
8var _postcssValueParser = require("postcss-value-parser");
9
10var _cssnanoUtils = require("cssnano-utils");
11
12var _addSpace = _interopRequireDefault(require("../lib/addSpace"));
13
14var _getValue = _interopRequireDefault(require("../lib/getValue"));
15
16function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
17
18// transition: [ none | <single-transition-property> ] || <time> || <single-transition-timing-function> || <time>
19const timingFunctions = ['ease', 'linear', 'ease-in', 'ease-out', 'ease-in-out', 'step-start', 'step-end'];
20
21function normalizeTransition(parsed) {
22 let args = (0, _cssnanoUtils.getArguments)(parsed);
23 let values = args.reduce((list, arg) => {
24 let state = {
25 timingFunction: [],
26 property: [],
27 time1: [],
28 time2: []
29 };
30 arg.forEach(node => {
31 const {
32 type,
33 value
34 } = node;
35
36 if (type === 'space') {
37 return;
38 }
39
40 if (type === 'function' && ~['steps', 'cubic-bezier'].indexOf(value.toLowerCase())) {
41 state.timingFunction = [...state.timingFunction, node, (0, _addSpace.default)()];
42 } else if ((0, _postcssValueParser.unit)(value)) {
43 if (!state.time1.length) {
44 state.time1 = [...state.time1, node, (0, _addSpace.default)()];
45 } else {
46 state.time2 = [...state.time2, node, (0, _addSpace.default)()];
47 }
48 } else if (~timingFunctions.indexOf(value.toLowerCase())) {
49 state.timingFunction = [...state.timingFunction, node, (0, _addSpace.default)()];
50 } else {
51 state.property = [...state.property, node, (0, _addSpace.default)()];
52 }
53 });
54 return [...list, [...state.property, ...state.time1, ...state.timingFunction, ...state.time2]];
55 }, []);
56 return (0, _getValue.default)(values);
57}
58
59module.exports = exports.default;
Note: See TracBrowser for help on using the repository browser.