victory-core 30.6.1 → 31.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (71) hide show
  1. package/README.md +13 -12
  2. package/dist/victory-core.js +1083 -842
  3. package/dist/victory-core.min.js +1 -1
  4. package/es/victory-animation/victory-animation.js +26 -21
  5. package/es/victory-label/victory-label.js +8 -2
  6. package/es/victory-primitives/path-helpers.js +1 -1
  7. package/es/victory-transition/victory-transition.js +11 -6
  8. package/es/victory-util/add-events.js +66 -38
  9. package/es/victory-util/axis.js +35 -9
  10. package/es/victory-util/data.js +24 -9
  11. package/es/victory-util/domain.js +15 -7
  12. package/es/victory-util/events.js +1 -1
  13. package/es/victory-util/helpers.js +17 -5
  14. package/es/victory-util/label-helpers.js +3 -5
  15. package/es/victory-util/textsize.js +20 -20
  16. package/es/victory-util/transitions.js +16 -16
  17. package/es/victory-util/wrapper.js +56 -19
  18. package/lib/victory-animation/victory-animation.js +27 -21
  19. package/lib/victory-label/victory-label.js +8 -2
  20. package/lib/victory-primitives/path-helpers.js +1 -1
  21. package/lib/victory-transition/victory-transition.js +12 -6
  22. package/lib/victory-util/add-events.js +66 -38
  23. package/lib/victory-util/axis.js +36 -9
  24. package/lib/victory-util/data.js +25 -9
  25. package/lib/victory-util/domain.js +16 -8
  26. package/lib/victory-util/events.js +1 -1
  27. package/lib/victory-util/helpers.js +17 -5
  28. package/lib/victory-util/label-helpers.js +3 -5
  29. package/lib/victory-util/textsize.js +20 -20
  30. package/lib/victory-util/transitions.js +16 -16
  31. package/lib/victory-util/wrapper.js +56 -19
  32. package/package.json +1 -1
  33. package/src/victory-animation/util.js +47 -45
  34. package/src/victory-animation/victory-animation.js +66 -38
  35. package/src/victory-clip-container/victory-clip-container.js +44 -31
  36. package/src/victory-container/victory-container.js +35 -21
  37. package/src/victory-label/victory-label.js +55 -71
  38. package/src/victory-portal/portal.js +1 -1
  39. package/src/victory-portal/victory-portal.js +10 -7
  40. package/src/victory-primitives/arc.js +15 -4
  41. package/src/victory-primitives/border.js +26 -5
  42. package/src/victory-primitives/circle.js +14 -3
  43. package/src/victory-primitives/clip-path.js +2 -7
  44. package/src/victory-primitives/line-segment.js +28 -5
  45. package/src/victory-primitives/line.js +15 -2
  46. package/src/victory-primitives/path-helpers.js +6 -7
  47. package/src/victory-primitives/point.js +30 -11
  48. package/src/victory-primitives/rect.js +19 -3
  49. package/src/victory-primitives/text.js +21 -11
  50. package/src/victory-primitives/tspan.js +6 -4
  51. package/src/victory-primitives/whisker.js +13 -6
  52. package/src/victory-theme/grayscale.js +153 -128
  53. package/src/victory-theme/material.js +178 -149
  54. package/src/victory-transition/victory-transition.js +31 -25
  55. package/src/victory-util/add-events.js +113 -75
  56. package/src/victory-util/axis.js +89 -35
  57. package/src/victory-util/collection.js +3 -8
  58. package/src/victory-util/common-props.js +42 -36
  59. package/src/victory-util/data.js +78 -43
  60. package/src/victory-util/domain.js +68 -46
  61. package/src/victory-util/events.js +129 -112
  62. package/src/victory-util/helpers.js +36 -16
  63. package/src/victory-util/immutable.js +12 -7
  64. package/src/victory-util/label-helpers.js +34 -18
  65. package/src/victory-util/prop-types.js +11 -23
  66. package/src/victory-util/scale.js +2 -3
  67. package/src/victory-util/selection.js +4 -5
  68. package/src/victory-util/style.js +17 -10
  69. package/src/victory-util/textsize.js +35 -31
  70. package/src/victory-util/transitions.js +53 -35
  71. package/src/victory-util/wrapper.js +112 -56
@@ -10,15 +10,13 @@ import PropTypes from "prop-types";
10
10
  * @param {Function} validator Validation function.
11
11
  * @returns {Function} Validator with `isRequired` option.
12
12
  */
13
- const makeChainable = function (validator) {
13
+ const makeChainable = function(validator) {
14
14
  /* eslint-disable max-params */
15
- const _chainable = function (isRequired, props, propName, componentName, ...rest) {
15
+ const _chainable = function(isRequired, props, propName, componentName, ...rest) {
16
16
  const value = props[propName];
17
17
  if (value === undefined || value === null) {
18
18
  if (isRequired) {
19
- return new Error(
20
- `Required \`${propName}\` was not specified in \`${componentName}\`.`
21
- );
19
+ return new Error(`Required \`${propName}\` was not specified in \`${componentName}\`.`);
22
20
  }
23
21
  return null;
24
22
  }
@@ -76,9 +74,7 @@ export default {
76
74
  return (props, propName, componentName) => {
77
75
  const value = props[propName];
78
76
  if (value !== null && value !== undefined) {
79
- Log.warn(
80
- `"${propName}" property of "${componentName}" has been deprecated ${explanation}`
81
- );
77
+ Log.warn(`"${propName}" property of "${componentName}" has been deprecated ${explanation}`);
82
78
  }
83
79
  return PropTypes.checkPropTypes({ [propName]: propType }, props, propName, componentName);
84
80
  };
@@ -106,9 +102,7 @@ export default {
106
102
  nonNegative: makeChainable((props, propName, componentName) => {
107
103
  const value = props[propName];
108
104
  if (typeof value !== "number" || value < 0) {
109
- return new Error(
110
- `\`${propName}\` in \`${componentName}\` must be a non-negative number.`
111
- );
105
+ return new Error(`\`${propName}\` in \`${componentName}\` must be a non-negative number.`);
112
106
  }
113
107
  return undefined;
114
108
  }),
@@ -119,9 +113,7 @@ export default {
119
113
  integer: makeChainable((props, propName, componentName) => {
120
114
  const value = props[propName];
121
115
  if (typeof value !== "number" || value % 1 !== 0) {
122
- return new Error(
123
- `\`${propName}\` in \`${componentName}\` must be an integer.`
124
- );
116
+ return new Error(`\`${propName}\` in \`${componentName}\` must be an integer.`);
125
117
  }
126
118
  return undefined;
127
119
  }),
@@ -159,7 +151,7 @@ export default {
159
151
  const supportedScaleStrings = ["linear", "time", "log", "sqrt"];
160
152
  const validScale = (scl) => {
161
153
  if (isFunction(scl)) {
162
- return (isFunction(scl.copy) && isFunction(scl.domain) && isFunction(scl.range));
154
+ return isFunction(scl.copy) && isFunction(scl.domain) && isFunction(scl.range);
163
155
  } else if (typeof scl === "string") {
164
156
  return supportedScaleStrings.indexOf(scl) !== -1;
165
157
  }
@@ -168,9 +160,7 @@ export default {
168
160
 
169
161
  const value = props[propName];
170
162
  if (!validScale(value)) {
171
- return new Error(
172
- `\`${propName}\` in \`${componentName}\` must be a d3 scale.`
173
- );
163
+ return new Error(`\`${propName}\` in \`${componentName}\` must be a d3 scale.`);
174
164
  }
175
165
  return undefined;
176
166
  }),
@@ -181,9 +171,7 @@ export default {
181
171
  homogeneousArray: makeChainable((props, propName, componentName) => {
182
172
  const values = props[propName];
183
173
  if (!Array.isArray(values)) {
184
- return new Error(
185
- `\`${propName}\` in \`${componentName}\` must be an array.`
186
- );
174
+ return new Error(`\`${propName}\` in \`${componentName}\` must be an array.`);
187
175
  }
188
176
 
189
177
  if (values.length < 2) {
@@ -202,8 +190,8 @@ export default {
202
190
 
203
191
  return new Error(
204
192
  `Expected \`${propName}\` in \`${componentName}\` to be a ` +
205
- `homogeneous array, but found types \`${constructorName}\` and ` +
206
- `\`${otherConstructorName}\`.`
193
+ `homogeneous array, but found types \`${constructorName}\` and ` +
194
+ `\`${otherConstructorName}\`.`
207
195
  );
208
196
  }
209
197
  return undefined;
@@ -17,7 +17,7 @@ function toNewName(scale) {
17
17
 
18
18
  function validScale(scale) {
19
19
  if (typeof scale === "function") {
20
- return (isFunction(scale.copy) && isFunction(scale.domain) && isFunction(scale.range));
20
+ return isFunction(scale.copy) && isFunction(scale.domain) && isFunction(scale.range);
21
21
  } else if (typeof scale === "string") {
22
22
  return includes(supportedScaleStrings, scale);
23
23
  }
@@ -70,8 +70,7 @@ function getBaseScale(props, axis) {
70
70
  if (scale) {
71
71
  return scale;
72
72
  }
73
- const defaultScale =
74
- getScaleFromDomain(props, axis) || getScaleTypeFromData(props, axis);
73
+ const defaultScale = getScaleFromDomain(props, axis) || getScaleTypeFromData(props, axis);
75
74
  return d3Scale[toNewName(defaultScale)]();
76
75
  }
77
76
 
@@ -7,8 +7,7 @@ import Collection from "./collection";
7
7
 
8
8
  function transformTarget(target, matrix, dimension) {
9
9
  const { a, d, e, f } = matrix;
10
- return dimension === "y" ?
11
- d * target + f : a * target + e;
10
+ return dimension === "y" ? d * target + f : a * target + e;
12
11
  }
13
12
 
14
13
  function getTransformationMatrix(svg) {
@@ -70,8 +69,8 @@ function getDataCoordinates(props, scale, x, y) {
70
69
  const origin = props.origin || { x: 0, y: 0 };
71
70
  const baseX = x - origin.x;
72
71
  const baseY = y - origin.y;
73
- const radius = Math.abs(baseX * Math.sqrt(1 + Math.pow((-baseY / baseX), 2)));
74
- const angle = (-Math.atan2(baseY, baseX) + (Math.PI * 2)) % (Math.PI * 2);
72
+ const radius = Math.abs(baseX * Math.sqrt(1 + Math.pow(-baseY / baseX, 2)));
73
+ const angle = (-Math.atan2(baseY, baseX) + Math.PI * 2) % (Math.PI * 2);
75
74
  return {
76
75
  x: scale.x.invert(angle),
77
76
  y: scale.y.invert(radius)
@@ -84,7 +83,7 @@ function getBounds(props) {
84
83
  const point1 = getDataCoordinates(props, scale, x1, y1);
85
84
  const point2 = getDataCoordinates(props, scale, x2, y2);
86
85
  const makeBound = (a, b) => {
87
- return [ Collection.getMinValue([a, b]), Collection.getMaxValue([a, b]) ];
86
+ return [Collection.getMinValue([a, b]), Collection.getMaxValue([a, b])];
88
87
  };
89
88
 
90
89
  return {
@@ -7,11 +7,13 @@
7
7
  * @param {Object} obj An object of transform definitions.
8
8
  * @returns {String} The generated transform string.
9
9
  */
10
- const toTransformString = function (obj, ...more) {
10
+ const toTransformString = function(obj, ...more) {
11
11
  if (more.length > 0) {
12
- return more.reduce((memo, currentObj) => {
13
- return [memo, toTransformString(currentObj)].join(" ");
14
- }, toTransformString(obj)).trim();
12
+ return more
13
+ .reduce((memo, currentObj) => {
14
+ return [memo, toTransformString(currentObj)].join(" ");
15
+ }, toTransformString(obj))
16
+ .trim();
15
17
  } else {
16
18
  if (obj === undefined || obj === null || typeof obj === "string") {
17
19
  return obj;
@@ -28,7 +30,6 @@ const toTransformString = function (obj, ...more) {
28
30
  };
29
31
 
30
32
  export default {
31
-
32
33
  toTransformString,
33
34
 
34
35
  /**
@@ -40,12 +41,18 @@ export default {
40
41
  */
41
42
  getColorScale(name) {
42
43
  const scales = {
43
- grayscale: [
44
- "#cccccc", "#969696", "#636363", "#252525"
45
- ],
44
+ grayscale: ["#cccccc", "#969696", "#636363", "#252525"],
46
45
  qualitative: [
47
- "#334D5C", "#45B29D", "#EFC94C", "#E27A3F", "#DF5A49",
48
- "#4F7DA1", "#55DBC1", "#EFDA97", "#E2A37F", "#DF948A"
46
+ "#334D5C",
47
+ "#45B29D",
48
+ "#EFC94C",
49
+ "#E27A3F",
50
+ "#DF5A49",
51
+ "#4F7DA1",
52
+ "#55DBC1",
53
+ "#EFDA97",
54
+ "#E2A37F",
55
+ "#DF948A"
49
56
  ],
50
57
  heatmap: ["#428517", "#77D200", "#D6D305", "#EC8E19", "#C92B05"],
51
58
  warm: ["#940031", "#C43343", "#DC5429", "#FF821D", "#FFAF55"],
@@ -4,39 +4,39 @@ import { assign, defaults } from "lodash";
4
4
 
5
5
  const fontDictionary = {
6
6
  "American Typewriter": 2.09,
7
- "Baskerville": 2.51,
8
- "Georgia": 2.27,
7
+ Baskerville: 2.51,
8
+ Georgia: 2.27,
9
9
  "Hoefler Text": 2.39,
10
- "Palatino": 2.26,
10
+ Palatino: 2.26,
11
11
  "Times New Roman": 2.48,
12
- "Arial": 2.26,
12
+ Arial: 2.26,
13
13
  "Gill Sans": 2.47,
14
14
  "Gill Sans 300": 2.58,
15
15
  "Helvetica Neue": 2.24,
16
16
  "Lucida Grande": 2.05,
17
- "Tahoma": 2.25,
17
+ Tahoma: 2.25,
18
18
  "Trebuchet MS": 2.2,
19
- "Verdana": 1.96,
19
+ Verdana: 1.96,
20
20
  "Courier New": 1.67,
21
- "cursive": 1.84,
22
- "fantasy": 2.09,
23
- "monospace": 1.81,
24
- "serif": 2.04,
21
+ cursive: 1.84,
22
+ fantasy: 2.09,
23
+ monospace: 1.81,
24
+ serif: 2.04,
25
25
  "sans-serif": 1.89
26
26
  };
27
27
  //https://developer.mozilla.org/en/docs/Web/CSS/length
28
28
  // Absolute sizes in pixels for obsolete measurement units.
29
29
  const absoluteMeasurementUnitsToPixels = {
30
- "mm": 3.8,
31
- "sm": 38,
32
- "pt": 1.33,
33
- "pc": 16,
34
- "in": 96,
35
- "px": 1
30
+ mm: 3.8,
31
+ sm: 38,
32
+ pt: 1.33,
33
+ pc: 16,
34
+ in: 96,
35
+ px: 1
36
36
  };
37
37
  const relativeMeasurementUnitsCoef = {
38
- "em": 1,
39
- "ex": 0.5
38
+ em: 1,
39
+ ex: 0.5
40
40
  };
41
41
 
42
42
  const coefficients = {
@@ -54,7 +54,7 @@ const defaultStyle = {
54
54
  fontFamily: ""
55
55
  };
56
56
 
57
- const _degreeToRadian = (angle) => angle * Math.PI / 180;
57
+ const _degreeToRadian = (angle) => (angle * Math.PI) / 180;
58
58
 
59
59
  const _getFontCharacterConstant = (fontFamily) => {
60
60
  const firstFont = fontFamily.split(",")[0].replace(/'|"/g, "");
@@ -67,8 +67,9 @@ const _splitToLines = (text) => {
67
67
 
68
68
  const _getSizeWithRotate = (axisSize, dependentSize, angle) => {
69
69
  const angleInRadian = _degreeToRadian(angle);
70
- return Math.abs(Math.cos(angleInRadian) * axisSize)
71
- + Math.abs(Math.sin(angleInRadian) * dependentSize);
70
+ return (
71
+ Math.abs(Math.cos(angleInRadian) * axisSize) + Math.abs(Math.sin(angleInRadian) * dependentSize)
72
+ );
72
73
  };
73
74
 
74
75
  /**
@@ -76,7 +77,7 @@ const _getSizeWithRotate = (axisSize, dependentSize, angle) => {
76
77
  * @param {string} length Css length string value.
77
78
  * @param {number} fontSize Current text font-size.
78
79
  * @returns {number} Approximate Css length in pixels.
79
- */
80
+ */
80
81
  const convertLengthToPixels = (length, fontSize) => {
81
82
  const attribute = length.match(/[a-zA-Z%]+/)[0];
82
83
  const value = length.match(/[0-9.,]+/);
@@ -84,8 +85,9 @@ const convertLengthToPixels = (length, fontSize) => {
84
85
  if (absoluteMeasurementUnitsToPixels.hasOwnProperty(attribute)) {
85
86
  result = value * absoluteMeasurementUnitsToPixels[attribute];
86
87
  } else if (relativeMeasurementUnitsCoef.hasOwnProperty(attribute)) {
87
- result = (fontSize ? value * fontSize : value * defaultStyle.fontSize)
88
- * relativeMeasurementUnitsCoef[attribute];
88
+ result =
89
+ (fontSize ? value * fontSize : value * defaultStyle.fontSize) *
90
+ relativeMeasurementUnitsCoef[attribute];
89
91
  } else {
90
92
  result = value;
91
93
  }
@@ -98,9 +100,10 @@ const _prepareParams = (inputStyle, index) => {
98
100
  return assign({}, style, {
99
101
  characterConstant: style.characterConstant || _getFontCharacterConstant(style.fontFamily),
100
102
  letterSpacing: convertLengthToPixels(style.letterSpacing, style.fontSize),
101
- fontSize: typeof (style.fontSize) === "number"
102
- ? style.fontSize
103
- : convertLengthToPixels(String(style.fontSize))
103
+ fontSize:
104
+ typeof style.fontSize === "number"
105
+ ? style.fontSize
106
+ : convertLengthToPixels(String(style.fontSize))
104
107
  });
105
108
  };
106
109
 
@@ -111,7 +114,7 @@ const _approximateTextWidthInternal = (text, style) => {
111
114
  const widths = _splitToLines(text).map((line, index) => {
112
115
  const len = line.toString().length;
113
116
  const { fontSize, characterConstant, letterSpacing } = _prepareParams(style, index);
114
- return (len * fontSize / characterConstant) + letterSpacing * (Math.max(len - 1, 0));
117
+ return (len * fontSize) / characterConstant + letterSpacing * Math.max(len - 1, 0);
115
118
  });
116
119
  return Math.max(...widths);
117
120
  };
@@ -123,8 +126,9 @@ const _approximateTextHeightInternal = (text, style) => {
123
126
  return _splitToLines(text).reduce((total, line, index) => {
124
127
  const lineStyle = _prepareParams(style, index);
125
128
  const containsCaps = line.toString().match(/[(A-Z)(0-9)]/);
126
- const height = containsCaps ?
127
- lineStyle.fontSize * coefficients.lineCapitalCoef : lineStyle.fontSize;
129
+ const height = containsCaps
130
+ ? lineStyle.fontSize * coefficients.lineCapitalCoef
131
+ : lineStyle.fontSize;
128
132
  const emptySpace = index === 0 ? 0 : lineStyle.fontSize * coefficients.lineSpaceHeightCoef;
129
133
  return total + lineStyle.lineHeight * (height + emptySpace);
130
134
  }, 0);
@@ -141,7 +145,7 @@ const _approximateTextHeightInternal = (text, style) => {
141
145
  * @param {number} style.characterConstant Average pixels per glyph.
142
146
  * @param {number} style.lineHeight Line height coefficient.
143
147
  * @returns {number} Approximate text label height.
144
- */
148
+ */
145
149
  const approximateTextSize = (text, style) => {
146
150
  const angle = Array.isArray(style) ? style[0] && style[0].angle : style && style.angle;
147
151
  const height = _approximateTextHeightInternal(text, style);
@@ -53,7 +53,7 @@ function getChildData(child) {
53
53
  if (child.type && child.type.getData) {
54
54
  return child.type.getData(child.props);
55
55
  }
56
- return child.props && child.props.data || false;
56
+ return (child.props && child.props.data) || false;
57
57
  }
58
58
 
59
59
  /**
@@ -127,7 +127,8 @@ function getInitialChildProps(animate, data) {
127
127
  };
128
128
  }
129
129
 
130
- function getChildBeforeLoad(animate, child, data, cb) { // eslint-disable-line max-params
130
+ // eslint-disable-next-line max-params
131
+ function getChildBeforeLoad(animate, child, data, cb) {
131
132
  animate = assign({}, animate, { onEnd: cb });
132
133
  if (animate && animate.onLoad && !animate.onLoad.duration) {
133
134
  return { animate, data };
@@ -141,7 +142,8 @@ function getChildBeforeLoad(animate, child, data, cb) { // eslint-disable-line m
141
142
  return { animate, data, clipWidth: 0 };
142
143
  }
143
144
 
144
- function getChildOnLoad(animate, data, cb) { // eslint-disable-line max-params
145
+ // eslint-disable-next-line max-params
146
+ function getChildOnLoad(animate, data, cb) {
145
147
  animate = assign({}, animate, { onEnd: cb });
146
148
  if (animate && animate.onLoad && !animate.onLoad.duration) {
147
149
  return { animate, data };
@@ -155,7 +157,8 @@ function getChildOnLoad(animate, data, cb) { // eslint-disable-line max-params
155
157
  return { animate, data };
156
158
  }
157
159
 
158
- function getChildPropsOnExit(animate, child, data, exitingNodes, cb) { // eslint-disable-line max-params, max-len
160
+ // eslint-disable-next-line max-params, max-len
161
+ function getChildPropsOnExit(animate, child, data, exitingNodes, cb) {
159
162
  // Whether or not _this_ child has exiting nodes, we want the exit-
160
163
  // transition for all children to have the same duration, delay, etc.
161
164
  const onExit = animate && animate.onExit;
@@ -176,7 +179,8 @@ function getChildPropsOnExit(animate, child, data, exitingNodes, cb) { // eslint
176
179
  return { animate, data };
177
180
  }
178
181
 
179
- function getChildPropsBeforeEnter(animate, child, data, enteringNodes, cb) { // eslint-disable-line max-params,max-len
182
+ // eslint-disable-next-line max-params,max-len
183
+ function getChildPropsBeforeEnter(animate, child, data, enteringNodes, cb) {
180
184
  if (enteringNodes) {
181
185
  // Perform a normal animation here, except - when it finishes - trigger
182
186
  // the transition for entering nodes.
@@ -194,7 +198,8 @@ function getChildPropsBeforeEnter(animate, child, data, enteringNodes, cb) { //
194
198
  return { animate, data };
195
199
  }
196
200
 
197
- function getChildPropsOnEnter(animate, data, enteringNodes, cb) { // eslint-disable-line max-params, max-len
201
+ // eslint-disable-next-line max-params, max-len
202
+ function getChildPropsOnEnter(animate, data, enteringNodes, cb) {
198
203
  // Whether or not _this_ child has entering nodes, we want the entering-
199
204
  // transition for all children to have the same duration, delay, etc.
200
205
  const onEnter = animate && animate.onEnter;
@@ -238,7 +243,7 @@ function getTransitionPropsFactory(props, state, setState) {
238
243
  const nodesShouldEnter = state && state.nodesShouldEnter;
239
244
  const nodesShouldLoad = state && state.nodesShouldLoad;
240
245
  const nodesDoneLoad = state && state.nodesDoneLoad;
241
- const childrenTransitions = state && state.childrenTransitions || [];
246
+ const childrenTransitions = (state && state.childrenTransitions) || [];
242
247
  const transitionDurations = {
243
248
  enter: props.animate && props.animate.onEnter && props.animate.onEnter.duration,
244
249
  exit: props.animate && props.animate.onExit && props.animate.onExit.duration,
@@ -258,13 +263,15 @@ function getTransitionPropsFactory(props, state, setState) {
258
263
  });
259
264
  };
260
265
 
261
- const onExit = (nodes, child, data, animate) => { // eslint-disable-line max-params
266
+ // eslint-disable-next-line max-params
267
+ const onExit = (nodes, child, data, animate) => {
262
268
  return getChildPropsOnExit(animate, child, data, nodes, () => {
263
269
  setState({ nodesWillExit: false });
264
270
  });
265
271
  };
266
272
 
267
- const onEnter = (nodes, child, data, animate) => { // eslint-disable-line max-params
273
+ // eslint-disable-next-line max-params
274
+ const onEnter = (nodes, child, data, animate) => {
268
275
  if (nodesShouldEnter) {
269
276
  return getChildPropsOnEnter(animate, data, nodes, () => {
270
277
  setState({ nodesWillEnter: false });
@@ -276,61 +283,72 @@ function getTransitionPropsFactory(props, state, setState) {
276
283
  });
277
284
  };
278
285
 
279
- const getChildTransitionDuration = function (child, type) {
286
+ const getChildTransitionDuration = function(child, type) {
280
287
  const animate = child.props.animate;
281
288
  if (!child.type) {
282
289
  return {};
283
290
  }
284
- const defaultTransitions = child.props && child.props.polar ?
285
- child.type.defaultPolarTransitions || child.type.defaultTransitions :
286
- child.type.defaultTransitions;
291
+ const defaultTransitions =
292
+ child.props && child.props.polar
293
+ ? child.type.defaultPolarTransitions || child.type.defaultTransitions
294
+ : child.type.defaultTransitions;
287
295
  if (defaultTransitions) {
288
296
  const animationDuration = animate[type] && animate[type].duration;
289
- return animationDuration !== undefined ?
290
- animationDuration : defaultTransitions[type] && defaultTransitions[type].duration;
297
+ return animationDuration !== undefined
298
+ ? animationDuration
299
+ : defaultTransitions[type] && defaultTransitions[type].duration;
291
300
  } else {
292
301
  return {};
293
302
  }
294
303
  };
295
304
 
296
- return function getTransitionProps(child, index) { // eslint-disable-line max-statements, complexity, max-len
305
+ // eslint-disable-next-line max-statements, complexity, max-len
306
+ return function getTransitionProps(child, index) {
297
307
  const data = getChildData(child) || [];
298
308
  const animate = defaults({}, props.animate, child.props.animate);
299
- const defaultTransitions = child.props.polar ?
300
- child.type.defaultPolarTransitions || child.type.defaultTransitions :
301
- child.type.defaultTransitions;
309
+ const defaultTransitions = child.props.polar
310
+ ? child.type.defaultPolarTransitions || child.type.defaultTransitions
311
+ : child.type.defaultTransitions;
302
312
 
303
- animate.onExit = defaults(
304
- {}, animate.onExit, defaultTransitions && defaultTransitions.onExit
305
- );
313
+ animate.onExit = defaults({}, animate.onExit, defaultTransitions && defaultTransitions.onExit);
306
314
  animate.onEnter = defaults(
307
- {}, animate.onEnter, defaultTransitions && defaultTransitions.onEnter
308
- );
309
- animate.onLoad = defaults(
310
- {}, animate.onLoad, defaultTransitions && defaultTransitions.onLoad
315
+ {},
316
+ animate.onEnter,
317
+ defaultTransitions && defaultTransitions.onEnter
311
318
  );
319
+ animate.onLoad = defaults({}, animate.onLoad, defaultTransitions && defaultTransitions.onLoad);
312
320
 
313
321
  const childTransitions = childrenTransitions[index] || childrenTransitions[0];
314
322
  if (!nodesDoneLoad) {
315
323
  // should do onLoad animation
316
- const load = transitionDurations.load !== undefined ?
317
- transitionDurations.load : getChildTransitionDuration(child, "onLoad");
324
+ const load =
325
+ transitionDurations.load !== undefined
326
+ ? transitionDurations.load
327
+ : getChildTransitionDuration(child, "onLoad");
318
328
  const animation = { duration: load };
319
329
  return onLoad(child, data, assign({}, animate, animation));
320
330
  } else if (nodesWillExit) {
321
331
  const exitingNodes = childTransitions && childTransitions.exiting;
322
- const exit = transitionDurations.exit !== undefined ?
323
- transitionDurations.exit : getChildTransitionDuration(child, "onExit");
332
+ const exit =
333
+ transitionDurations.exit !== undefined
334
+ ? transitionDurations.exit
335
+ : getChildTransitionDuration(child, "onExit");
324
336
  // if nodesWillExit, but this child has no exiting nodes, set a delay instead of a duration
325
337
  const animation = exitingNodes ? { duration: exit } : { delay: exit };
326
338
  return onExit(exitingNodes, child, data, assign({}, animate, animation));
327
339
  } else if (nodesWillEnter) {
328
340
  const enteringNodes = childTransitions && childTransitions.entering;
329
- const enter = transitionDurations.enter !== undefined ?
330
- transitionDurations.enter : getChildTransitionDuration(child, "onEnter");
331
- const move = transitionDurations.move !== undefined ?
332
- transitionDurations.move : child.props.animate && child.props.animate.duration;
333
- const animation = { duration: nodesShouldEnter && enteringNodes ? enter : move };
341
+ const enter =
342
+ transitionDurations.enter !== undefined
343
+ ? transitionDurations.enter
344
+ : getChildTransitionDuration(child, "onEnter");
345
+ const move =
346
+ transitionDurations.move !== undefined
347
+ ? transitionDurations.move
348
+ : child.props.animate && child.props.animate.duration;
349
+ const animation = {
350
+ duration: nodesShouldEnter && enteringNodes ? enter : move
351
+ };
334
352
  return onEnter(enteringNodes, child, data, assign({}, animate, animation));
335
353
  } else if (!state && animate && animate.onExit) {
336
354
  // This is the initial render, and nodes may enter when props change. Because