@remotion/transitions 4.0.137 → 4.0.138
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/build.ts +30 -0
- package/dist/esm/clock-wipe.mjs +63 -43
- package/dist/esm/fade.mjs +31 -27
- package/dist/esm/flip.mjs +58 -46
- package/dist/esm/index.mjs +328 -257
- package/dist/esm/slide.mjs +77 -70
- package/dist/esm/wipe.mjs +115 -85
- package/package.json +11 -12
- package/dist/cjs/TransitionSeries.d.ts +0 -15
- package/dist/cjs/fade.js +0 -25
- package/dist/cjs/flatten-children.d.ts +0 -2
- package/dist/cjs/flip.js +0 -40
- package/dist/cjs/index.d.ts +0 -4
- package/dist/cjs/index.js +0 -280
- package/dist/cjs/presentations/fade.d.ts +0 -3
- package/dist/cjs/presentations/flip.d.ts +0 -7
- package/dist/cjs/presentations/slide.d.ts +0 -6
- package/dist/cjs/presentations/wipe.d.ts +0 -6
- package/dist/cjs/slide.js +0 -72
- package/dist/cjs/test/transitions.test.d.ts +0 -1
- package/dist/cjs/timings/linear-timing.d.ts +0 -5
- package/dist/cjs/timings/spring-timing.d.ts +0 -7
- package/dist/cjs/types.d.ts +0 -27
- package/dist/cjs/validate.d.ts +0 -2
- package/dist/cjs/wipe.js +0 -158
- package/rollup.config.js +0 -52
package/dist/esm/index.mjs
CHANGED
|
@@ -1,278 +1,349 @@
|
|
|
1
|
-
|
|
2
|
-
import {
|
|
3
|
-
import
|
|
4
|
-
import {
|
|
5
|
-
|
|
6
|
-
|
|
1
|
+
// src/presentations/slide.tsx
|
|
2
|
+
import {useMemo} from "react";
|
|
3
|
+
import {AbsoluteFill} from "remotion";
|
|
4
|
+
import {
|
|
5
|
+
jsx
|
|
6
|
+
} from "react/jsx-runtime";
|
|
7
|
+
var epsilon = 0.01;
|
|
8
|
+
var SlidePresentation = ({
|
|
9
|
+
children,
|
|
10
|
+
presentationProgress,
|
|
11
|
+
presentationDirection,
|
|
12
|
+
passedProps: { direction = "from-left", enterStyle, exitStyle }
|
|
13
|
+
}) => {
|
|
14
|
+
const directionStyle = useMemo(() => {
|
|
15
|
+
const presentationProgressWithEpsilonCorrection = presentationProgress === 1 ? presentationProgress * 100 : presentationProgress * 100 - epsilon;
|
|
16
|
+
if (presentationDirection === "exiting") {
|
|
17
|
+
switch (direction) {
|
|
18
|
+
case "from-left":
|
|
19
|
+
return {
|
|
20
|
+
transform: `translateX(${presentationProgressWithEpsilonCorrection}%)`
|
|
21
|
+
};
|
|
22
|
+
case "from-right":
|
|
23
|
+
return {
|
|
24
|
+
transform: `translateX(-${presentationProgress * 100}%)`
|
|
25
|
+
};
|
|
26
|
+
case "from-top":
|
|
27
|
+
return {
|
|
28
|
+
transform: `translateY(${presentationProgressWithEpsilonCorrection}%)`
|
|
29
|
+
};
|
|
30
|
+
case "from-bottom":
|
|
31
|
+
return {
|
|
32
|
+
transform: `translateY(-${presentationProgress * 100}%)`
|
|
33
|
+
};
|
|
34
|
+
default:
|
|
35
|
+
throw new Error(`Invalid direction: ${direction}`);
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
switch (direction) {
|
|
39
|
+
case "from-left":
|
|
40
|
+
return {
|
|
41
|
+
transform: `translateX(${-100 + presentationProgress * 100}%)`
|
|
42
|
+
};
|
|
43
|
+
case "from-right":
|
|
44
|
+
return {
|
|
45
|
+
transform: `translateX(${100 - presentationProgressWithEpsilonCorrection}%)`
|
|
46
|
+
};
|
|
47
|
+
case "from-top":
|
|
48
|
+
return {
|
|
49
|
+
transform: `translateY(${-100 + presentationProgress * 100}%)`
|
|
50
|
+
};
|
|
51
|
+
case "from-bottom":
|
|
52
|
+
return {
|
|
53
|
+
transform: `translateY(${100 - presentationProgressWithEpsilonCorrection}%)`
|
|
54
|
+
};
|
|
55
|
+
default:
|
|
56
|
+
throw new Error(`Invalid direction: ${direction}`);
|
|
57
|
+
}
|
|
58
|
+
}, [presentationDirection, presentationProgress, direction]);
|
|
59
|
+
const style = useMemo(() => {
|
|
7
60
|
return {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
extrapolateLeft: 'clamp',
|
|
15
|
-
extrapolateRight: 'clamp',
|
|
16
|
-
});
|
|
17
|
-
},
|
|
61
|
+
width: "100%",
|
|
62
|
+
height: "100%",
|
|
63
|
+
justifyContent: "center",
|
|
64
|
+
alignItems: "center",
|
|
65
|
+
...directionStyle,
|
|
66
|
+
...presentationDirection === "entering" ? enterStyle : exitStyle
|
|
18
67
|
};
|
|
68
|
+
}, [directionStyle, enterStyle, exitStyle, presentationDirection]);
|
|
69
|
+
return jsx(AbsoluteFill, {
|
|
70
|
+
style,
|
|
71
|
+
children
|
|
72
|
+
}, undefined, false, undefined, this);
|
|
73
|
+
};
|
|
74
|
+
var slide = (props) => {
|
|
75
|
+
return {
|
|
76
|
+
component: SlidePresentation,
|
|
77
|
+
props: props ?? {}
|
|
78
|
+
};
|
|
19
79
|
};
|
|
20
80
|
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
81
|
+
// src/timings/linear-timing.ts
|
|
82
|
+
import {interpolate} from "remotion";
|
|
83
|
+
var linearTiming = (options) => {
|
|
84
|
+
return {
|
|
85
|
+
getDurationInFrames: () => {
|
|
86
|
+
return options.durationInFrames;
|
|
87
|
+
},
|
|
88
|
+
getProgress: ({ frame }) => {
|
|
89
|
+
return interpolate(frame, [0, options.durationInFrames], [0, 1], {
|
|
90
|
+
easing: options.easing,
|
|
91
|
+
extrapolateLeft: "clamp",
|
|
92
|
+
extrapolateRight: "clamp"
|
|
93
|
+
});
|
|
24
94
|
}
|
|
25
|
-
|
|
26
|
-
};
|
|
27
|
-
const springTiming = (options = {}) => {
|
|
28
|
-
return {
|
|
29
|
-
getDurationInFrames: ({ fps }) => {
|
|
30
|
-
if (options.durationInFrames) {
|
|
31
|
-
return options.durationInFrames;
|
|
32
|
-
}
|
|
33
|
-
return measureSpring({
|
|
34
|
-
config: options.config,
|
|
35
|
-
threshold: options.durationRestThreshold,
|
|
36
|
-
fps,
|
|
37
|
-
});
|
|
38
|
-
},
|
|
39
|
-
getProgress: ({ fps, frame }) => {
|
|
40
|
-
return springWithInvalidArgumentRejection({
|
|
41
|
-
fps,
|
|
42
|
-
frame,
|
|
43
|
-
config: options.config,
|
|
44
|
-
durationInFrames: options.durationInFrames,
|
|
45
|
-
durationRestThreshold: options.durationRestThreshold,
|
|
46
|
-
});
|
|
47
|
-
},
|
|
48
|
-
};
|
|
95
|
+
};
|
|
49
96
|
};
|
|
50
97
|
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
flatChildren.push(child);
|
|
59
|
-
return flatChildren;
|
|
60
|
-
}, []);
|
|
98
|
+
// src/timings/spring-timing.ts
|
|
99
|
+
import {measureSpring, spring} from "remotion";
|
|
100
|
+
var springWithInvalidArgumentRejection = (args) => {
|
|
101
|
+
if (args.to || args.from) {
|
|
102
|
+
throw new Error("to / from values are not supported by springWithRoundUpIfThreshold");
|
|
103
|
+
}
|
|
104
|
+
return spring(args);
|
|
61
105
|
};
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
};
|
|
85
|
-
case 'from-bottom':
|
|
86
|
-
return {
|
|
87
|
-
transform: `translateY(-${presentationProgress * 100}%)`,
|
|
88
|
-
};
|
|
89
|
-
default:
|
|
90
|
-
throw new Error(`Invalid direction: ${direction}`);
|
|
91
|
-
}
|
|
92
|
-
}
|
|
93
|
-
switch (direction) {
|
|
94
|
-
case 'from-left':
|
|
95
|
-
return {
|
|
96
|
-
transform: `translateX(${-100 + presentationProgress * 100}%)`,
|
|
97
|
-
};
|
|
98
|
-
case 'from-right':
|
|
99
|
-
return {
|
|
100
|
-
transform: `translateX(${100 - presentationProgressWithEpsilonCorrection}%)`,
|
|
101
|
-
};
|
|
102
|
-
case 'from-top':
|
|
103
|
-
return {
|
|
104
|
-
transform: `translateY(${-100 + presentationProgress * 100}%)`,
|
|
105
|
-
};
|
|
106
|
-
case 'from-bottom':
|
|
107
|
-
return {
|
|
108
|
-
transform: `translateY(${100 - presentationProgressWithEpsilonCorrection}%)`,
|
|
109
|
-
};
|
|
110
|
-
default:
|
|
111
|
-
throw new Error(`Invalid direction: ${direction}`);
|
|
112
|
-
}
|
|
113
|
-
}, [presentationDirection, presentationProgress, direction]);
|
|
114
|
-
const style = useMemo(() => {
|
|
115
|
-
return {
|
|
116
|
-
width: '100%',
|
|
117
|
-
height: '100%',
|
|
118
|
-
justifyContent: 'center',
|
|
119
|
-
alignItems: 'center',
|
|
120
|
-
...directionStyle,
|
|
121
|
-
...(presentationDirection === 'entering' ? enterStyle : exitStyle),
|
|
122
|
-
};
|
|
123
|
-
}, [directionStyle, enterStyle, exitStyle, presentationDirection]);
|
|
124
|
-
return jsx(AbsoluteFill, { style: style, children: children });
|
|
106
|
+
var springTiming = (options = {}) => {
|
|
107
|
+
return {
|
|
108
|
+
getDurationInFrames: ({ fps }) => {
|
|
109
|
+
if (options.durationInFrames) {
|
|
110
|
+
return options.durationInFrames;
|
|
111
|
+
}
|
|
112
|
+
return measureSpring({
|
|
113
|
+
config: options.config,
|
|
114
|
+
threshold: options.durationRestThreshold,
|
|
115
|
+
fps
|
|
116
|
+
});
|
|
117
|
+
},
|
|
118
|
+
getProgress: ({ fps, frame }) => {
|
|
119
|
+
return springWithInvalidArgumentRejection({
|
|
120
|
+
fps,
|
|
121
|
+
frame,
|
|
122
|
+
config: options.config,
|
|
123
|
+
durationInFrames: options.durationInFrames,
|
|
124
|
+
durationRestThreshold: options.durationRestThreshold
|
|
125
|
+
});
|
|
126
|
+
}
|
|
127
|
+
};
|
|
125
128
|
};
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
129
|
+
|
|
130
|
+
// src/TransitionSeries.tsx
|
|
131
|
+
import {Children, useMemo as useMemo2} from "react";
|
|
132
|
+
import {Internals, Sequence, useCurrentFrame, useVideoConfig} from "remotion";
|
|
133
|
+
|
|
134
|
+
// src/flatten-children.ts
|
|
135
|
+
import React2 from "react";
|
|
136
|
+
var flattenChildren = (children) => {
|
|
137
|
+
const childrenArray = React2.Children.toArray(children);
|
|
138
|
+
return childrenArray.reduce((flatChildren, child) => {
|
|
139
|
+
if (child.type === React2.Fragment) {
|
|
140
|
+
return flatChildren.concat(flattenChildren(child.props.children));
|
|
141
|
+
}
|
|
142
|
+
flatChildren.push(child);
|
|
143
|
+
return flatChildren;
|
|
144
|
+
}, []);
|
|
131
145
|
};
|
|
132
146
|
|
|
133
|
-
|
|
134
|
-
|
|
147
|
+
// src/validate.ts
|
|
148
|
+
import {NoReactInternals} from "remotion/no-react";
|
|
149
|
+
var validateDurationInFrames = NoReactInternals.validateDurationInFrames;
|
|
135
150
|
|
|
136
|
-
//
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
151
|
+
// src/TransitionSeries.tsx
|
|
152
|
+
import {
|
|
153
|
+
jsx as jsx2,
|
|
154
|
+
Fragment
|
|
155
|
+
} from "react/jsx-runtime";
|
|
156
|
+
var TransitionSeriesTransition = function(_props) {
|
|
157
|
+
return null;
|
|
141
158
|
};
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
159
|
+
var SeriesSequence = ({ children }) => {
|
|
160
|
+
return jsx2(Fragment, {
|
|
161
|
+
children
|
|
162
|
+
}, undefined, false, undefined, this);
|
|
145
163
|
};
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
}
|
|
208
|
-
const currentStartFrame = startFrame + offset;
|
|
209
|
-
let duration = 0;
|
|
210
|
-
if (prev) {
|
|
211
|
-
duration = prev.props.timing.getDurationInFrames({
|
|
212
|
-
fps,
|
|
213
|
-
});
|
|
214
|
-
transitionOffsets -= duration;
|
|
215
|
-
}
|
|
216
|
-
let actualStartFrame = currentStartFrame + transitionOffsets;
|
|
217
|
-
startFrame += durationInFramesProp + offset;
|
|
218
|
-
// Handle the case where the first item is a transition
|
|
219
|
-
if (actualStartFrame < 0) {
|
|
220
|
-
startFrame -= actualStartFrame;
|
|
221
|
-
actualStartFrame = 0;
|
|
222
|
-
}
|
|
223
|
-
const nextProgress = next
|
|
224
|
-
? next.props.timing.getProgress({
|
|
225
|
-
frame: frame -
|
|
226
|
-
actualStartFrame -
|
|
227
|
-
durationInFrames +
|
|
228
|
-
next.props.timing.getDurationInFrames({ fps }),
|
|
229
|
-
fps,
|
|
230
|
-
})
|
|
231
|
-
: null;
|
|
232
|
-
const prevProgress = prev
|
|
233
|
-
? prev.props.timing.getProgress({
|
|
234
|
-
frame: frame - actualStartFrame,
|
|
235
|
-
fps,
|
|
236
|
-
})
|
|
237
|
-
: null;
|
|
238
|
-
if (next &&
|
|
239
|
-
durationInFramesProp < next.props.timing.getDurationInFrames({ fps })) {
|
|
240
|
-
throw new Error(`The duration of a <TransitionSeries.Sequence /> must not be shorter than the duration of the next <TransitionSeries.Transition />. The transition is ${next.props.timing.getDurationInFrames({ fps })} frames long, but the sequence is only ${durationInFramesProp} frames long (${debugInfo})`);
|
|
241
|
-
}
|
|
242
|
-
if (prev &&
|
|
243
|
-
durationInFramesProp < prev.props.timing.getDurationInFrames({ fps })) {
|
|
244
|
-
throw new Error(`The duration of a <TransitionSeries.Sequence /> must not be shorter than the duration of the previous <TransitionSeries.Transition />. The transition is ${prev.props.timing.getDurationInFrames({ fps })} frames long, but the sequence is only ${durationInFramesProp} frames long (${debugInfo})`);
|
|
245
|
-
}
|
|
246
|
-
if (next && prev && nextProgress !== null && prevProgress !== null) {
|
|
247
|
-
const nextPresentation = (_b = next.props.presentation) !== null && _b !== void 0 ? _b : slide();
|
|
248
|
-
const prevPresentation = (_c = prev.props.presentation) !== null && _c !== void 0 ? _c : slide();
|
|
249
|
-
const UppercaseNextPresentation = nextPresentation.component;
|
|
250
|
-
const UppercasePrevPresentation = prevPresentation.component;
|
|
251
|
-
return (jsx(Sequence, { name: passedProps.name || '<TS.Sequence>', from: Math.floor(actualStartFrame), durationInFrames: durationInFramesProp, layout: "none", stack: passedProps.stack, children: jsx(UppercaseNextPresentation, { passedProps: (_d = nextPresentation.props) !== null && _d !== void 0 ? _d : {}, presentationDirection: "exiting", presentationProgress: nextProgress, children: jsx(UppercasePrevPresentation, { passedProps: (_e = prevPresentation.props) !== null && _e !== void 0 ? _e : {}, presentationDirection: "entering", presentationProgress: prevProgress, children: jsx(Sequence, { showInTimeline: false, ...passedProps, children: child }) }) }) }));
|
|
252
|
-
}
|
|
253
|
-
if (prevProgress !== null && prev) {
|
|
254
|
-
const prevPresentation = (_f = prev.props.presentation) !== null && _f !== void 0 ? _f : slide();
|
|
255
|
-
const UppercasePrevPresentation = prevPresentation.component;
|
|
256
|
-
return (jsx(Sequence, { name: passedProps.name || '<TS.Sequence>', from: Math.floor(actualStartFrame), durationInFrames: durationInFramesProp, layout: "none", stack: passedProps.stack, children: jsx(UppercasePrevPresentation, { passedProps: (_g = prevPresentation.props) !== null && _g !== void 0 ? _g : {}, presentationDirection: "entering", presentationProgress: prevProgress, children: jsx(Sequence, { showInTimeline: false, ...passedProps, children: child }) }) }));
|
|
257
|
-
}
|
|
258
|
-
if (nextProgress !== null && next) {
|
|
259
|
-
const nextPresentation = (_h = next.props.presentation) !== null && _h !== void 0 ? _h : slide();
|
|
260
|
-
const UppercaseNextPresentation = nextPresentation.component;
|
|
261
|
-
return (jsx(Sequence, { name: passedProps.name || '<TS.Sequence>', from: Math.floor(actualStartFrame), durationInFrames: durationInFramesProp, layout: "none", stack: passedProps.stack, children: jsx(UppercaseNextPresentation, { passedProps: (_j = nextPresentation.props) !== null && _j !== void 0 ? _j : {}, presentationDirection: "exiting", presentationProgress: nextProgress, children: jsx(Sequence, { showInTimeline: false, ...passedProps, children: child }) }) }));
|
|
262
|
-
}
|
|
263
|
-
return (jsx(Sequence, { name: passedProps.name || '<TS.Sequence>', from: Math.floor(actualStartFrame), durationInFrames: durationInFramesProp, ...passedProps, children: child }));
|
|
164
|
+
var TransitionSeriesChildren = ({
|
|
165
|
+
children
|
|
166
|
+
}) => {
|
|
167
|
+
const { fps } = useVideoConfig();
|
|
168
|
+
const frame = useCurrentFrame();
|
|
169
|
+
const childrenValue = useMemo2(() => {
|
|
170
|
+
let transitionOffsets = 0;
|
|
171
|
+
let startFrame = 0;
|
|
172
|
+
const flattedChildren = flattenChildren(children);
|
|
173
|
+
return Children.map(flattedChildren, (child, i) => {
|
|
174
|
+
const current = child;
|
|
175
|
+
if (typeof current === "string") {
|
|
176
|
+
if (current.trim() === "") {
|
|
177
|
+
return null;
|
|
178
|
+
}
|
|
179
|
+
throw new TypeError(`The <TransitionSeries /> component only accepts a list of <TransitionSeries.Sequence /> components as its children, but you passed a string "${current}"`);
|
|
180
|
+
}
|
|
181
|
+
const hasPrev = flattedChildren[i - 1];
|
|
182
|
+
const nextPrev = flattedChildren[i + 1];
|
|
183
|
+
const prev = typeof hasPrev === "string" || typeof hasPrev === "undefined" ? null : hasPrev.type === TransitionSeriesTransition ? hasPrev : null;
|
|
184
|
+
const next = typeof nextPrev === "string" || typeof nextPrev === "undefined" ? null : nextPrev.type === TransitionSeriesTransition ? nextPrev : null;
|
|
185
|
+
const prevIsTransition = typeof hasPrev === "string" || typeof hasPrev === "undefined" ? false : hasPrev.type === TransitionSeriesTransition;
|
|
186
|
+
if (current.type === TransitionSeriesTransition) {
|
|
187
|
+
if (prevIsTransition) {
|
|
188
|
+
throw new TypeError(`A <TransitionSeries.Transition /> component must not be followed by another <TransitionSeries.Transition /> component (nth children = ${i - 1} and ${i})`);
|
|
189
|
+
}
|
|
190
|
+
return null;
|
|
191
|
+
}
|
|
192
|
+
if (current.type !== SeriesSequence) {
|
|
193
|
+
throw new TypeError(`The <TransitionSeries /> component only accepts a list of <TransitionSeries.Sequence /> and <TransitionSeries.Transition /> components as its children, but got ${current} instead`);
|
|
194
|
+
}
|
|
195
|
+
const castedChildAgain = current;
|
|
196
|
+
const debugInfo = `index = ${i}, duration = ${castedChildAgain.props.durationInFrames}`;
|
|
197
|
+
if (!castedChildAgain?.props.children) {
|
|
198
|
+
throw new TypeError(`A <TransitionSeries.Sequence /> component (${debugInfo}) was detected to not have any children. Delete it to fix this error.`);
|
|
199
|
+
}
|
|
200
|
+
const durationInFramesProp = castedChildAgain.props.durationInFrames;
|
|
201
|
+
const {
|
|
202
|
+
durationInFrames,
|
|
203
|
+
children: _children,
|
|
204
|
+
...passedProps
|
|
205
|
+
} = castedChildAgain.props;
|
|
206
|
+
validateDurationInFrames(durationInFramesProp, {
|
|
207
|
+
component: `of a <TransitionSeries.Sequence /> component`,
|
|
208
|
+
allowFloats: true
|
|
209
|
+
});
|
|
210
|
+
const offset = castedChildAgain.props.offset ?? 0;
|
|
211
|
+
if (Number.isNaN(offset)) {
|
|
212
|
+
throw new TypeError(`The "offset" property of a <TransitionSeries.Sequence /> must not be NaN, but got NaN (${debugInfo}).`);
|
|
213
|
+
}
|
|
214
|
+
if (!Number.isFinite(offset)) {
|
|
215
|
+
throw new TypeError(`The "offset" property of a <TransitionSeries.Sequence /> must be finite, but got ${offset} (${debugInfo}).`);
|
|
216
|
+
}
|
|
217
|
+
if (offset % 1 !== 0) {
|
|
218
|
+
throw new TypeError(`The "offset" property of a <TransitionSeries.Sequence /> must be finite, but got ${offset} (${debugInfo}).`);
|
|
219
|
+
}
|
|
220
|
+
const currentStartFrame = startFrame + offset;
|
|
221
|
+
let duration = 0;
|
|
222
|
+
if (prev) {
|
|
223
|
+
duration = prev.props.timing.getDurationInFrames({
|
|
224
|
+
fps
|
|
264
225
|
});
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
226
|
+
transitionOffsets -= duration;
|
|
227
|
+
}
|
|
228
|
+
let actualStartFrame = currentStartFrame + transitionOffsets;
|
|
229
|
+
startFrame += durationInFramesProp + offset;
|
|
230
|
+
if (actualStartFrame < 0) {
|
|
231
|
+
startFrame -= actualStartFrame;
|
|
232
|
+
actualStartFrame = 0;
|
|
233
|
+
}
|
|
234
|
+
const nextProgress = next ? next.props.timing.getProgress({
|
|
235
|
+
frame: frame - actualStartFrame - durationInFrames + next.props.timing.getDurationInFrames({ fps }),
|
|
236
|
+
fps
|
|
237
|
+
}) : null;
|
|
238
|
+
const prevProgress = prev ? prev.props.timing.getProgress({
|
|
239
|
+
frame: frame - actualStartFrame,
|
|
240
|
+
fps
|
|
241
|
+
}) : null;
|
|
242
|
+
if (next && durationInFramesProp < next.props.timing.getDurationInFrames({ fps })) {
|
|
243
|
+
throw new Error(`The duration of a <TransitionSeries.Sequence /> must not be shorter than the duration of the next <TransitionSeries.Transition />. The transition is ${next.props.timing.getDurationInFrames({ fps })} frames long, but the sequence is only ${durationInFramesProp} frames long (${debugInfo})`);
|
|
244
|
+
}
|
|
245
|
+
if (prev && durationInFramesProp < prev.props.timing.getDurationInFrames({ fps })) {
|
|
246
|
+
throw new Error(`The duration of a <TransitionSeries.Sequence /> must not be shorter than the duration of the previous <TransitionSeries.Transition />. The transition is ${prev.props.timing.getDurationInFrames({ fps })} frames long, but the sequence is only ${durationInFramesProp} frames long (${debugInfo})`);
|
|
247
|
+
}
|
|
248
|
+
if (next && prev && nextProgress !== null && prevProgress !== null) {
|
|
249
|
+
const nextPresentation = next.props.presentation ?? slide();
|
|
250
|
+
const prevPresentation = prev.props.presentation ?? slide();
|
|
251
|
+
const UppercaseNextPresentation = nextPresentation.component;
|
|
252
|
+
const UppercasePrevPresentation = prevPresentation.component;
|
|
253
|
+
return jsx2(Sequence, {
|
|
254
|
+
name: passedProps.name || "<TS.Sequence>",
|
|
255
|
+
from: Math.floor(actualStartFrame),
|
|
256
|
+
durationInFrames: durationInFramesProp,
|
|
257
|
+
layout: "none",
|
|
258
|
+
stack: passedProps.stack,
|
|
259
|
+
children: jsx2(UppercaseNextPresentation, {
|
|
260
|
+
passedProps: nextPresentation.props ?? {},
|
|
261
|
+
presentationDirection: "exiting",
|
|
262
|
+
presentationProgress: nextProgress,
|
|
263
|
+
children: jsx2(UppercasePrevPresentation, {
|
|
264
|
+
passedProps: prevPresentation.props ?? {},
|
|
265
|
+
presentationDirection: "entering",
|
|
266
|
+
presentationProgress: prevProgress,
|
|
267
|
+
children: jsx2(Sequence, {
|
|
268
|
+
showInTimeline: false,
|
|
269
|
+
...passedProps,
|
|
270
|
+
children: child
|
|
271
|
+
}, undefined, false, undefined, this)
|
|
272
|
+
}, undefined, false, undefined, this)
|
|
273
|
+
}, undefined, false, undefined, this)
|
|
274
|
+
}, undefined, false, undefined, this);
|
|
275
|
+
}
|
|
276
|
+
if (prevProgress !== null && prev) {
|
|
277
|
+
const prevPresentation = prev.props.presentation ?? slide();
|
|
278
|
+
const UppercasePrevPresentation = prevPresentation.component;
|
|
279
|
+
return jsx2(Sequence, {
|
|
280
|
+
name: passedProps.name || "<TS.Sequence>",
|
|
281
|
+
from: Math.floor(actualStartFrame),
|
|
282
|
+
durationInFrames: durationInFramesProp,
|
|
283
|
+
layout: "none",
|
|
284
|
+
stack: passedProps.stack,
|
|
285
|
+
children: jsx2(UppercasePrevPresentation, {
|
|
286
|
+
passedProps: prevPresentation.props ?? {},
|
|
287
|
+
presentationDirection: "entering",
|
|
288
|
+
presentationProgress: prevProgress,
|
|
289
|
+
children: jsx2(Sequence, {
|
|
290
|
+
showInTimeline: false,
|
|
291
|
+
...passedProps,
|
|
292
|
+
children: child
|
|
293
|
+
}, undefined, false, undefined, this)
|
|
294
|
+
}, undefined, false, undefined, this)
|
|
295
|
+
}, undefined, false, undefined, this);
|
|
296
|
+
}
|
|
297
|
+
if (nextProgress !== null && next) {
|
|
298
|
+
const nextPresentation = next.props.presentation ?? slide();
|
|
299
|
+
const UppercaseNextPresentation = nextPresentation.component;
|
|
300
|
+
return jsx2(Sequence, {
|
|
301
|
+
name: passedProps.name || "<TS.Sequence>",
|
|
302
|
+
from: Math.floor(actualStartFrame),
|
|
303
|
+
durationInFrames: durationInFramesProp,
|
|
304
|
+
layout: "none",
|
|
305
|
+
stack: passedProps.stack,
|
|
306
|
+
children: jsx2(UppercaseNextPresentation, {
|
|
307
|
+
passedProps: nextPresentation.props ?? {},
|
|
308
|
+
presentationDirection: "exiting",
|
|
309
|
+
presentationProgress: nextProgress,
|
|
310
|
+
children: jsx2(Sequence, {
|
|
311
|
+
showInTimeline: false,
|
|
312
|
+
...passedProps,
|
|
313
|
+
children: child
|
|
314
|
+
}, undefined, false, undefined, this)
|
|
315
|
+
}, undefined, false, undefined, this)
|
|
316
|
+
}, undefined, false, undefined, this);
|
|
317
|
+
}
|
|
318
|
+
return jsx2(Sequence, {
|
|
319
|
+
name: passedProps.name || "<TS.Sequence>",
|
|
320
|
+
from: Math.floor(actualStartFrame),
|
|
321
|
+
durationInFrames: durationInFramesProp,
|
|
322
|
+
...passedProps,
|
|
323
|
+
children: child
|
|
324
|
+
}, undefined, false, undefined, this);
|
|
325
|
+
});
|
|
326
|
+
}, [children, fps, frame]);
|
|
327
|
+
return jsx2(Fragment, {
|
|
328
|
+
children: childrenValue
|
|
329
|
+
}, undefined, false, undefined, this);
|
|
268
330
|
};
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
331
|
+
var TransitionSeries = ({ children, name, ...otherProps }) => {
|
|
332
|
+
const displayName = name ?? "<TransitionSeries>";
|
|
333
|
+
return jsx2(Sequence, {
|
|
334
|
+
name: displayName,
|
|
335
|
+
...otherProps,
|
|
336
|
+
children: jsx2(TransitionSeriesChildren, {
|
|
337
|
+
children
|
|
338
|
+
}, undefined, false, undefined, this)
|
|
339
|
+
}, undefined, false, undefined, this);
|
|
272
340
|
};
|
|
273
341
|
TransitionSeries.Sequence = SeriesSequence;
|
|
274
342
|
TransitionSeries.Transition = TransitionSeriesTransition;
|
|
275
343
|
Internals.addSequenceStackTraces(TransitionSeries);
|
|
276
344
|
Internals.addSequenceStackTraces(SeriesSequence);
|
|
277
|
-
|
|
278
|
-
|
|
345
|
+
export {
|
|
346
|
+
springTiming,
|
|
347
|
+
linearTiming,
|
|
348
|
+
TransitionSeries
|
|
349
|
+
};
|