victory-core 36.9.2 → 37.0.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.
- package/CHANGELOG.md +6 -0
- package/dist/victory-core.js +4371 -5749
- package/dist/victory-core.min.js +1 -1
- package/es/victory-accessible-group/victory-accessible-group.js +9 -15
- package/es/victory-animation/util.js +28 -47
- package/es/victory-animation/victory-animation.js +51 -67
- package/es/victory-clip-container/victory-clip-container.js +153 -229
- package/es/victory-container/victory-container.js +157 -216
- package/es/victory-label/victory-label.js +246 -323
- package/es/victory-portal/portal-context.js +1 -2
- package/es/victory-portal/portal.js +30 -76
- package/es/victory-portal/victory-portal.js +47 -104
- package/es/victory-primitives/arc.js +44 -47
- package/es/victory-primitives/background.js +14 -17
- package/es/victory-primitives/border.js +20 -24
- package/es/victory-primitives/circle.js +13 -27
- package/es/victory-primitives/clip-path.js +3 -7
- package/es/victory-primitives/line-segment.js +20 -24
- package/es/victory-primitives/line.js +13 -27
- package/es/victory-primitives/path.js +13 -27
- package/es/victory-primitives/point.js +36 -40
- package/es/victory-primitives/rect.js +13 -27
- package/es/victory-primitives/text.js +15 -28
- package/es/victory-primitives/tspan.js +13 -26
- package/es/victory-primitives/whisker.js +43 -47
- package/es/victory-theme/grayscale.js +22 -22
- package/es/victory-theme/material.js +46 -46
- package/es/victory-theme/victory-theme.js +3 -3
- package/es/victory-transition/victory-transition.js +126 -206
- package/es/victory-util/add-events.js +263 -374
- package/es/victory-util/axis.js +126 -222
- package/es/victory-util/collection.js +13 -41
- package/es/victory-util/data.js +159 -214
- package/es/victory-util/default-transitions.js +33 -51
- package/es/victory-util/domain.js +122 -171
- package/es/victory-util/events.js +168 -258
- package/es/victory-util/helpers.js +153 -178
- package/es/victory-util/hooks/use-animation-state.js +61 -99
- package/es/victory-util/hooks/use-previous-props.js +2 -2
- package/es/victory-util/immutable.js +6 -8
- package/es/victory-util/label-helpers.js +128 -130
- package/es/victory-util/line-helpers.js +29 -41
- package/es/victory-util/log.js +1 -1
- package/es/victory-util/point-path-helpers.js +89 -49
- package/es/victory-util/scale.js +24 -42
- package/es/victory-util/selection.js +39 -40
- package/es/victory-util/style.js +8 -13
- package/es/victory-util/textsize.js +80 -154
- package/es/victory-util/timer-context.js +2 -2
- package/es/victory-util/timer.js +40 -76
- package/es/victory-util/transitions.js +110 -150
- package/es/victory-util/type-helpers.js +2 -3
- package/es/victory-util/user-props.js +24 -49
- package/es/victory-util/wrapper.js +184 -247
- package/lib/index.js +0 -30
- package/lib/victory-accessible-group/victory-accessible-group.js +9 -19
- package/lib/victory-animation/util.js +28 -63
- package/lib/victory-animation/victory-animation.js +54 -83
- package/lib/victory-clip-container/victory-clip-container.js +156 -243
- package/lib/victory-container/victory-container.js +160 -232
- package/lib/victory-label/victory-label.js +248 -344
- package/lib/victory-portal/portal-context.js +1 -6
- package/lib/victory-portal/portal.js +31 -81
- package/lib/victory-portal/victory-portal.js +50 -116
- package/lib/victory-primitives/arc.js +48 -57
- package/lib/victory-primitives/background.js +16 -28
- package/lib/victory-primitives/border.js +22 -34
- package/lib/victory-primitives/circle.js +16 -36
- package/lib/victory-primitives/clip-path.js +3 -11
- package/lib/victory-primitives/index.js +0 -28
- package/lib/victory-primitives/line-segment.js +22 -34
- package/lib/victory-primitives/line.js +16 -36
- package/lib/victory-primitives/path.js +16 -36
- package/lib/victory-primitives/point.js +38 -52
- package/lib/victory-primitives/rect.js +16 -36
- package/lib/victory-primitives/text.js +15 -33
- package/lib/victory-primitives/tspan.js +13 -31
- package/lib/victory-primitives/whisker.js +45 -57
- package/lib/victory-theme/grayscale.js +23 -24
- package/lib/victory-theme/material.js +47 -48
- package/lib/victory-theme/victory-theme.js +2 -7
- package/lib/victory-transition/victory-transition.js +129 -224
- package/lib/victory-util/add-events.js +263 -380
- package/lib/victory-util/axis.js +128 -241
- package/lib/victory-util/collection.js +13 -50
- package/lib/victory-util/data.js +160 -239
- package/lib/victory-util/default-transitions.js +33 -54
- package/lib/victory-util/domain.js +123 -193
- package/lib/victory-util/events.js +167 -274
- package/lib/victory-util/helpers.js +156 -207
- package/lib/victory-util/hooks/index.js +0 -2
- package/lib/victory-util/hooks/use-animation-state.js +63 -113
- package/lib/victory-util/hooks/use-previous-props.js +2 -7
- package/lib/victory-util/immutable.js +6 -18
- package/lib/victory-util/index.js +2 -51
- package/lib/victory-util/label-helpers.js +130 -141
- package/lib/victory-util/line-helpers.js +31 -49
- package/lib/victory-util/log.js +1 -2
- package/lib/victory-util/point-path-helpers.js +91 -63
- package/lib/victory-util/scale.js +26 -57
- package/lib/victory-util/selection.js +41 -49
- package/lib/victory-util/style.js +8 -16
- package/lib/victory-util/textsize.js +80 -157
- package/lib/victory-util/timer-context.js +2 -8
- package/lib/victory-util/timer.js +40 -76
- package/lib/victory-util/transitions.js +110 -152
- package/lib/victory-util/type-helpers.js +2 -9
- package/lib/victory-util/user-props.js +25 -59
- package/lib/victory-util/wrapper.js +186 -281
- package/package.json +2 -2
|
@@ -5,39 +5,32 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.getInitialTransitionState = getInitialTransitionState;
|
|
7
7
|
exports.getTransitionPropsFactory = getTransitionPropsFactory;
|
|
8
|
-
|
|
9
8
|
var _identity2 = _interopRequireDefault(require("lodash/identity"));
|
|
10
|
-
|
|
11
9
|
var _defaults2 = _interopRequireDefault(require("lodash/defaults"));
|
|
12
|
-
|
|
13
10
|
var _react = _interopRequireDefault(require("react"));
|
|
14
|
-
|
|
15
11
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
16
|
-
|
|
17
12
|
function getDatumKey(datum, idx) {
|
|
18
13
|
return (datum.key || idx).toString();
|
|
19
14
|
}
|
|
20
|
-
|
|
21
15
|
function getKeyedData(data) {
|
|
22
|
-
return data.reduce(
|
|
23
|
-
|
|
16
|
+
return data.reduce((keyedData, datum, idx) => {
|
|
17
|
+
const key = getDatumKey(datum, idx);
|
|
24
18
|
keyedData[key] = datum;
|
|
25
19
|
return keyedData;
|
|
26
20
|
}, {});
|
|
27
21
|
}
|
|
28
|
-
|
|
29
22
|
function getKeyedDataDifference(a, b) {
|
|
30
|
-
|
|
31
|
-
|
|
23
|
+
let hasDifference = false;
|
|
24
|
+
const difference = Object.keys(a).reduce((_difference, key) => {
|
|
32
25
|
if (!(key in b)) {
|
|
33
26
|
hasDifference = true;
|
|
34
27
|
_difference[key] = true;
|
|
35
28
|
}
|
|
36
|
-
|
|
37
29
|
return _difference;
|
|
38
30
|
}, {});
|
|
39
31
|
return hasDifference && difference;
|
|
40
32
|
}
|
|
33
|
+
|
|
41
34
|
/**
|
|
42
35
|
* Calculate which data-points exist in oldData and not nextData -
|
|
43
36
|
* these are the `exiting` data-points. Also calculate which
|
|
@@ -51,24 +44,21 @@ function getKeyedDataDifference(a, b) {
|
|
|
51
44
|
* entering[datum.key] will be true if the data is
|
|
52
45
|
* entering, and similarly for `exiting`.
|
|
53
46
|
*/
|
|
54
|
-
|
|
55
|
-
|
|
56
47
|
function getNodeTransitions(oldData, nextData) {
|
|
57
|
-
|
|
58
|
-
|
|
48
|
+
const oldDataKeyed = oldData && getKeyedData(oldData);
|
|
49
|
+
const nextDataKeyed = nextData && getKeyedData(nextData);
|
|
59
50
|
return {
|
|
60
51
|
entering: oldDataKeyed && getKeyedDataDifference(nextDataKeyed, oldDataKeyed),
|
|
61
52
|
exiting: nextDataKeyed && getKeyedDataDifference(oldDataKeyed, nextDataKeyed)
|
|
62
53
|
};
|
|
63
54
|
}
|
|
64
|
-
|
|
65
55
|
function getChildData(child) {
|
|
66
56
|
if (child.type && child.type.getData) {
|
|
67
57
|
return child.type.getData(child.props);
|
|
68
58
|
}
|
|
69
|
-
|
|
70
59
|
return child.props && child.props.data || false;
|
|
71
60
|
}
|
|
61
|
+
|
|
72
62
|
/**
|
|
73
63
|
* If a parent component has animation enabled, calculate the transitions
|
|
74
64
|
* for any data of any child component that supports data transitions.
|
|
@@ -85,21 +75,17 @@ function getChildData(child) {
|
|
|
85
75
|
* - childrenTransitions
|
|
86
76
|
* - nodesShouldEnter
|
|
87
77
|
*/
|
|
88
|
-
|
|
89
|
-
|
|
90
78
|
function getInitialTransitionState(oldChildren, nextChildren) {
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
var getTransition = function (oldChild, newChild) {
|
|
79
|
+
let nodesWillExit = false;
|
|
80
|
+
let nodesWillEnter = false;
|
|
81
|
+
const getTransition = (oldChild, newChild) => {
|
|
95
82
|
if (!newChild || oldChild.type !== newChild.type) {
|
|
96
83
|
return {};
|
|
97
84
|
}
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
85
|
+
const {
|
|
86
|
+
entering,
|
|
87
|
+
exiting
|
|
88
|
+
} = getNodeTransitions(getChildData(oldChild), getChildData(newChild)) || {};
|
|
103
89
|
nodesWillExit = nodesWillExit || !!exiting;
|
|
104
90
|
nodesWillEnter = nodesWillEnter || !!entering;
|
|
105
91
|
return {
|
|
@@ -107,23 +93,20 @@ function getInitialTransitionState(oldChildren, nextChildren) {
|
|
|
107
93
|
exiting: exiting || false
|
|
108
94
|
};
|
|
109
95
|
};
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
return old.map(function (child, idx) {
|
|
96
|
+
const getTransitionsFromChildren = (old, next) => {
|
|
97
|
+
return old.map((child, idx) => {
|
|
113
98
|
if (child && child.props && child.props.children && next[idx]) {
|
|
114
99
|
return getTransitionsFromChildren(_react.default.Children.toArray(old[idx].props.children), _react.default.Children.toArray(next[idx].props.children));
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
|
|
100
|
+
}
|
|
101
|
+
// get Transition entering and exiting nodes
|
|
118
102
|
return getTransition(child, next[idx]);
|
|
119
103
|
});
|
|
120
104
|
};
|
|
121
|
-
|
|
122
|
-
var childrenTransitions = getTransitionsFromChildren(_react.default.Children.toArray(oldChildren), _react.default.Children.toArray(nextChildren));
|
|
105
|
+
const childrenTransitions = getTransitionsFromChildren(_react.default.Children.toArray(oldChildren), _react.default.Children.toArray(nextChildren));
|
|
123
106
|
return {
|
|
124
|
-
nodesWillExit
|
|
125
|
-
nodesWillEnter
|
|
126
|
-
childrenTransitions
|
|
107
|
+
nodesWillExit,
|
|
108
|
+
nodesWillEnter,
|
|
109
|
+
childrenTransitions,
|
|
127
110
|
// TODO: This may need to be refactored for the following situation.
|
|
128
111
|
// The component receives new props, and the data provided
|
|
129
112
|
// is a perfect match for the previous data and domain except
|
|
@@ -132,32 +115,27 @@ function getInitialTransitionState(oldChildren, nextChildren) {
|
|
|
132
115
|
nodesShouldEnter: false
|
|
133
116
|
};
|
|
134
117
|
}
|
|
135
|
-
|
|
136
118
|
function getInitialChildProps(animate, data) {
|
|
137
|
-
|
|
119
|
+
const after = animate.onEnter && animate.onEnter.after ? animate.onEnter.after : _identity2.default;
|
|
138
120
|
return {
|
|
139
|
-
data: data.map(
|
|
140
|
-
return Object.assign({}, datum, after(datum, idx, data));
|
|
141
|
-
})
|
|
121
|
+
data: data.map((datum, idx) => Object.assign({}, datum, after(datum, idx, data)))
|
|
142
122
|
};
|
|
143
|
-
}
|
|
144
|
-
|
|
123
|
+
}
|
|
145
124
|
|
|
125
|
+
// eslint-disable-next-line max-params
|
|
146
126
|
function getChildBeforeLoad(animate, child, data, cb) {
|
|
147
|
-
|
|
127
|
+
const newAnimate = Object.assign({}, animate, {
|
|
148
128
|
onEnd: cb
|
|
149
129
|
});
|
|
150
|
-
|
|
151
130
|
if (newAnimate && newAnimate.onLoad && !newAnimate.onLoad.duration) {
|
|
152
131
|
return {
|
|
153
132
|
animate: newAnimate,
|
|
154
|
-
data
|
|
133
|
+
data
|
|
155
134
|
};
|
|
156
135
|
}
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
var newData = data.map(function (datum, idx) {
|
|
136
|
+
const before = newAnimate.onLoad && newAnimate.onLoad.before ? newAnimate.onLoad.before : _identity2.default;
|
|
137
|
+
// If nodes need to exit, transform them with the provided onLoad.before function.
|
|
138
|
+
const newData = data.map((datum, idx) => {
|
|
161
139
|
return Object.assign({}, datum, before(datum, idx, data));
|
|
162
140
|
});
|
|
163
141
|
return {
|
|
@@ -165,111 +143,104 @@ function getChildBeforeLoad(animate, child, data, cb) {
|
|
|
165
143
|
data: newData,
|
|
166
144
|
clipWidth: 0
|
|
167
145
|
};
|
|
168
|
-
}
|
|
169
|
-
|
|
146
|
+
}
|
|
170
147
|
|
|
148
|
+
// eslint-disable-next-line max-params
|
|
171
149
|
function getChildOnLoad(animate, data, cb) {
|
|
172
|
-
|
|
150
|
+
const newAnimate = Object.assign({}, animate, {
|
|
173
151
|
onEnd: cb
|
|
174
152
|
});
|
|
175
|
-
|
|
176
|
-
|
|
153
|
+
let newData = data;
|
|
177
154
|
if (newAnimate && newAnimate.onLoad && !newAnimate.onLoad.duration) {
|
|
178
155
|
return {
|
|
179
|
-
animate
|
|
180
|
-
data
|
|
156
|
+
animate,
|
|
157
|
+
data
|
|
181
158
|
};
|
|
182
159
|
}
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
newData = data.map(function (datum, idx) {
|
|
160
|
+
const after = animate.onLoad && animate.onLoad.after ? animate.onLoad.after : _identity2.default;
|
|
161
|
+
// If nodes need to exit, transform them with the provided onLoad.after function.
|
|
162
|
+
newData = data.map((datum, idx) => {
|
|
187
163
|
return Object.assign({}, datum, after(datum, idx, data));
|
|
188
164
|
});
|
|
189
165
|
return {
|
|
190
166
|
animate: newAnimate,
|
|
191
167
|
data: newData
|
|
192
168
|
};
|
|
193
|
-
}
|
|
194
|
-
|
|
169
|
+
}
|
|
195
170
|
|
|
171
|
+
// eslint-disable-next-line max-params, max-len
|
|
196
172
|
function getChildPropsOnExit(animate, child, data, exitingNodes, cb) {
|
|
197
173
|
// Whether or not _this_ child has exiting nodes, we want the exit-
|
|
198
174
|
// transition for all children to have the same duration, delay, etc.
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
175
|
+
const onExit = animate && animate.onExit;
|
|
176
|
+
const newAnimate = Object.assign({}, animate, onExit);
|
|
177
|
+
let newData = data;
|
|
203
178
|
if (exitingNodes) {
|
|
204
179
|
// After the exit transition occurs, trigger the animations for
|
|
205
180
|
// nodes that are neither exiting nor entering.
|
|
206
181
|
animate.onEnd = cb;
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
newData = data.map(
|
|
210
|
-
|
|
182
|
+
const before = animate.onExit && animate.onExit.before ? animate.onExit.before : _identity2.default;
|
|
183
|
+
// If nodes need to exit, transform them with the provided onExit.before function.
|
|
184
|
+
newData = data.map((datum, idx) => {
|
|
185
|
+
const key = (datum.key || idx).toString();
|
|
211
186
|
return exitingNodes[key] ? Object.assign({}, datum, before(datum, idx, data)) : datum;
|
|
212
187
|
});
|
|
213
188
|
}
|
|
214
|
-
|
|
215
189
|
return {
|
|
216
190
|
animate: newAnimate,
|
|
217
191
|
data: newData
|
|
218
192
|
};
|
|
219
|
-
}
|
|
220
|
-
|
|
193
|
+
}
|
|
221
194
|
|
|
195
|
+
// eslint-disable-next-line max-params,max-len
|
|
222
196
|
function getChildPropsBeforeEnter(animate, child, data, enteringNodes, cb) {
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
197
|
+
let newAnimate = animate;
|
|
198
|
+
let newData = data;
|
|
226
199
|
if (enteringNodes) {
|
|
227
200
|
// Perform a normal animation here, except - when it finishes - trigger
|
|
228
201
|
// the transition for entering nodes.
|
|
229
202
|
newAnimate = Object.assign({}, animate, {
|
|
230
203
|
onEnd: cb
|
|
231
204
|
});
|
|
232
|
-
|
|
205
|
+
const before = animate.onEnter && animate.onEnter.before ? animate.onEnter.before : _identity2.default;
|
|
206
|
+
// We want the entering nodes to be included in the transition target
|
|
233
207
|
// domain. However, we may not want these nodes to be displayed initially,
|
|
234
208
|
// so perform the `onEnter.before` transformation on each node.
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
var key = (datum.key || idx).toString();
|
|
209
|
+
newData = data.map((datum, idx) => {
|
|
210
|
+
const key = (datum.key || idx).toString();
|
|
238
211
|
return enteringNodes[key] ? Object.assign({}, datum, before(datum, idx, data)) : datum;
|
|
239
212
|
});
|
|
240
213
|
}
|
|
241
|
-
|
|
242
214
|
return {
|
|
243
215
|
animate: newAnimate,
|
|
244
216
|
data: newData
|
|
245
217
|
};
|
|
246
|
-
}
|
|
247
|
-
|
|
218
|
+
}
|
|
248
219
|
|
|
220
|
+
// eslint-disable-next-line max-params, max-len
|
|
249
221
|
function getChildPropsOnEnter(animate, data, enteringNodes, cb) {
|
|
250
222
|
// Whether or not _this_ child has entering nodes, we want the entering-
|
|
251
223
|
// transition for all children to have the same duration, delay, etc.
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
224
|
+
const onEnter = animate && animate.onEnter;
|
|
225
|
+
const newAnimate = Object.assign({}, animate, onEnter);
|
|
226
|
+
let newData = data;
|
|
256
227
|
if (enteringNodes) {
|
|
257
228
|
// Old nodes have been transitioned to their new values, and the
|
|
258
229
|
// domain should encompass the nodes that will now enter. So perform
|
|
259
230
|
// the `onEnter.after` transformation on each node.
|
|
260
231
|
newAnimate.onEnd = cb;
|
|
261
|
-
|
|
262
|
-
newData = data.map(
|
|
263
|
-
|
|
232
|
+
const after = newAnimate.onEnter && newAnimate.onEnter.after ? newAnimate.onEnter.after : _identity2.default;
|
|
233
|
+
newData = data.map((datum, idx) => {
|
|
234
|
+
const key = getDatumKey(datum, idx);
|
|
264
235
|
return enteringNodes[key] ? Object.assign({}, datum, after(datum, idx, data)) : datum;
|
|
265
236
|
});
|
|
266
237
|
}
|
|
267
|
-
|
|
268
238
|
return {
|
|
269
239
|
animate: newAnimate,
|
|
270
240
|
data: newData
|
|
271
241
|
};
|
|
272
242
|
}
|
|
243
|
+
|
|
273
244
|
/**
|
|
274
245
|
* getTransitionPropsFactory - putting the Java in JavaScript. This will return a
|
|
275
246
|
* function that returns prop transformations for a child, given that child's props
|
|
@@ -288,118 +259,106 @@ function getChildPropsOnEnter(animate, data, enteringNodes, cb) {
|
|
|
288
259
|
*
|
|
289
260
|
* @return {Function} Child-prop transformation function.
|
|
290
261
|
*/
|
|
291
|
-
|
|
292
|
-
|
|
293
262
|
function getTransitionPropsFactory(props, state, setState) {
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
263
|
+
const nodesWillExit = state && state.nodesWillExit;
|
|
264
|
+
const nodesWillEnter = state && state.nodesWillEnter;
|
|
265
|
+
const nodesShouldEnter = state && state.nodesShouldEnter;
|
|
266
|
+
const nodesShouldLoad = state && state.nodesShouldLoad;
|
|
267
|
+
const nodesDoneLoad = state && state.nodesDoneLoad;
|
|
268
|
+
const childrenTransitions = state && state.childrenTransitions || [];
|
|
269
|
+
const transitionDurations = {
|
|
301
270
|
enter: props.animate && props.animate.onEnter && props.animate.onEnter.duration,
|
|
302
271
|
exit: props.animate && props.animate.onExit && props.animate.onExit.duration,
|
|
303
272
|
load: props.animate && props.animate.onLoad && props.animate.onLoad.duration,
|
|
304
273
|
move: props.animate && props.animate.duration
|
|
305
274
|
};
|
|
306
|
-
|
|
307
|
-
var onLoad = function (child, data, animate) {
|
|
275
|
+
const onLoad = (child, data, animate) => {
|
|
308
276
|
if (nodesShouldLoad) {
|
|
309
|
-
return getChildOnLoad(animate, data,
|
|
277
|
+
return getChildOnLoad(animate, data, () => {
|
|
310
278
|
setState({
|
|
311
279
|
nodesShouldLoad: false,
|
|
312
280
|
nodesDoneLoad: true
|
|
313
281
|
});
|
|
314
282
|
});
|
|
315
283
|
}
|
|
316
|
-
|
|
317
|
-
return getChildBeforeLoad(animate, child, data, function () {
|
|
284
|
+
return getChildBeforeLoad(animate, child, data, () => {
|
|
318
285
|
setState({
|
|
319
286
|
nodesDoneLoad: true
|
|
320
287
|
});
|
|
321
288
|
});
|
|
322
|
-
};
|
|
323
|
-
|
|
289
|
+
};
|
|
324
290
|
|
|
325
|
-
|
|
326
|
-
|
|
291
|
+
// eslint-disable-next-line max-params
|
|
292
|
+
const onExit = (nodes, child, data, animate) => {
|
|
293
|
+
return getChildPropsOnExit(animate, child, data, nodes, () => {
|
|
327
294
|
setState({
|
|
328
295
|
nodesWillExit: false
|
|
329
296
|
});
|
|
330
297
|
});
|
|
331
|
-
};
|
|
332
|
-
|
|
298
|
+
};
|
|
333
299
|
|
|
334
|
-
|
|
300
|
+
// eslint-disable-next-line max-params
|
|
301
|
+
const onEnter = (nodes, child, data, animate) => {
|
|
335
302
|
if (nodesShouldEnter) {
|
|
336
|
-
return getChildPropsOnEnter(animate, data, nodes,
|
|
303
|
+
return getChildPropsOnEnter(animate, data, nodes, () => {
|
|
337
304
|
setState({
|
|
338
305
|
nodesWillEnter: false
|
|
339
306
|
});
|
|
340
307
|
});
|
|
341
308
|
}
|
|
342
|
-
|
|
343
|
-
return getChildPropsBeforeEnter(animate, child, data, nodes, function () {
|
|
309
|
+
return getChildPropsBeforeEnter(animate, child, data, nodes, () => {
|
|
344
310
|
setState({
|
|
345
311
|
nodesShouldEnter: true
|
|
346
312
|
});
|
|
347
313
|
});
|
|
348
314
|
};
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
var animate = child.props.animate;
|
|
352
|
-
|
|
315
|
+
const getChildTransitionDuration = function (child, type) {
|
|
316
|
+
const animate = child.props.animate;
|
|
353
317
|
if (!child.type) {
|
|
354
318
|
return {};
|
|
355
319
|
}
|
|
356
|
-
|
|
357
|
-
var defaultTransitions = child.props && child.props.polar ? child.type.defaultPolarTransitions || child.type.defaultTransitions : child.type.defaultTransitions;
|
|
358
|
-
|
|
320
|
+
const defaultTransitions = child.props && child.props.polar ? child.type.defaultPolarTransitions || child.type.defaultTransitions : child.type.defaultTransitions;
|
|
359
321
|
if (defaultTransitions) {
|
|
360
|
-
|
|
322
|
+
const animationDuration = animate[type] && animate[type].duration;
|
|
361
323
|
return animationDuration !== undefined ? animationDuration : defaultTransitions[type] && defaultTransitions[type].duration;
|
|
362
324
|
}
|
|
363
|
-
|
|
364
325
|
return {};
|
|
365
|
-
};
|
|
366
|
-
|
|
326
|
+
};
|
|
367
327
|
|
|
328
|
+
// eslint-disable-next-line max-statements, complexity, max-len
|
|
368
329
|
return function getTransitionProps(child, index) {
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
330
|
+
const data = getChildData(child) || [];
|
|
331
|
+
const animate = (0, _defaults2.default)({}, props.animate, child.props.animate);
|
|
332
|
+
const defaultTransitions = child.props.polar ? child.type.defaultPolarTransitions || child.type.defaultTransitions : child.type.defaultTransitions;
|
|
372
333
|
animate.onExit = (0, _defaults2.default)({}, animate.onExit, defaultTransitions && defaultTransitions.onExit);
|
|
373
334
|
animate.onEnter = (0, _defaults2.default)({}, animate.onEnter, defaultTransitions && defaultTransitions.onEnter);
|
|
374
335
|
animate.onLoad = (0, _defaults2.default)({}, animate.onLoad, defaultTransitions && defaultTransitions.onLoad);
|
|
375
|
-
|
|
376
|
-
|
|
336
|
+
const childTransitions = childrenTransitions[index] || childrenTransitions[0];
|
|
377
337
|
if (!nodesDoneLoad) {
|
|
378
338
|
// should do onLoad animation
|
|
379
|
-
|
|
380
|
-
|
|
339
|
+
const load = transitionDurations.load !== undefined ? transitionDurations.load : getChildTransitionDuration(child, "onLoad");
|
|
340
|
+
const animation = {
|
|
381
341
|
duration: load
|
|
382
342
|
};
|
|
383
343
|
return onLoad(child, data, Object.assign({}, animate, animation));
|
|
384
344
|
} else if (nodesWillExit) {
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
345
|
+
const exitingNodes = childTransitions && childTransitions.exiting;
|
|
346
|
+
const exit = transitionDurations.exit !== undefined ? transitionDurations.exit : getChildTransitionDuration(child, "onExit");
|
|
347
|
+
// if nodesWillExit, but this child has no exiting nodes, set a delay instead of a duration
|
|
348
|
+
const animation = exitingNodes ? {
|
|
389
349
|
duration: exit
|
|
390
350
|
} : {
|
|
391
351
|
delay: exit
|
|
392
352
|
};
|
|
393
|
-
|
|
394
|
-
return onExit(exitingNodes, child, data, Object.assign({}, animate, _animation));
|
|
353
|
+
return onExit(exitingNodes, child, data, Object.assign({}, animate, animation));
|
|
395
354
|
} else if (nodesWillEnter) {
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
355
|
+
const enteringNodes = childTransitions && childTransitions.entering;
|
|
356
|
+
const enter = transitionDurations.enter !== undefined ? transitionDurations.enter : getChildTransitionDuration(child, "onEnter");
|
|
357
|
+
const move = transitionDurations.move !== undefined ? transitionDurations.move : child.props.animate && child.props.animate.duration;
|
|
358
|
+
const animation = {
|
|
400
359
|
duration: nodesShouldEnter && enteringNodes ? enter : move
|
|
401
360
|
};
|
|
402
|
-
return onEnter(enteringNodes, child, data, Object.assign({}, animate,
|
|
361
|
+
return onEnter(enteringNodes, child, data, Object.assign({}, animate, animation));
|
|
403
362
|
} else if (!state && animate && animate.onExit) {
|
|
404
363
|
// This is the initial render, and nodes may enter when props change. Because
|
|
405
364
|
// animation interpolation is determined by old- and next- props, data may need
|
|
@@ -412,10 +371,9 @@ function getTransitionPropsFactory(props, state, setState) {
|
|
|
412
371
|
//
|
|
413
372
|
return getInitialChildProps(animate, data);
|
|
414
373
|
}
|
|
415
|
-
|
|
416
374
|
return {
|
|
417
|
-
animate
|
|
418
|
-
data
|
|
375
|
+
animate,
|
|
376
|
+
data
|
|
419
377
|
};
|
|
420
378
|
};
|
|
421
379
|
}
|
|
@@ -9,36 +9,29 @@ exports.isDate = isDate;
|
|
|
9
9
|
exports.isFunction = isFunction;
|
|
10
10
|
exports.isKeyValueObject = isKeyValueObject;
|
|
11
11
|
exports.isTuple = isTuple;
|
|
12
|
-
|
|
13
12
|
function hasValueForAxis(value, axis) {
|
|
14
13
|
if (typeof value === "object" && value !== null) {
|
|
15
14
|
return axis in value;
|
|
16
15
|
}
|
|
17
|
-
|
|
18
16
|
return false;
|
|
19
17
|
}
|
|
20
|
-
|
|
21
18
|
function isTuple(value) {
|
|
22
19
|
return Array.isArray(value) && value.length === 2;
|
|
23
20
|
}
|
|
24
|
-
|
|
25
21
|
function getValueForAxis(value, axis) {
|
|
26
22
|
if (hasValueForAxis(value, axis)) {
|
|
27
23
|
return value[axis];
|
|
28
24
|
}
|
|
29
|
-
|
|
30
25
|
return value;
|
|
31
|
-
}
|
|
32
|
-
|
|
26
|
+
}
|
|
33
27
|
|
|
28
|
+
// eslint-disable-next-line @typescript-eslint/ban-types
|
|
34
29
|
function isFunction(func) {
|
|
35
30
|
return typeof func === "function";
|
|
36
31
|
}
|
|
37
|
-
|
|
38
32
|
function isDate(value) {
|
|
39
33
|
return value instanceof Date;
|
|
40
34
|
}
|
|
41
|
-
|
|
42
35
|
function isKeyValueObject(datum) {
|
|
43
36
|
return typeof datum === "object" && !Array.isArray(datum) && !(datum instanceof Date);
|
|
44
37
|
}
|