@remotion/transitions 4.0.135 → 4.0.136
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/dist/cjs/TransitionSeries.d.ts +15 -0
- package/dist/cjs/fade.js +25 -0
- package/dist/cjs/flatten-children.d.ts +2 -0
- package/dist/cjs/flip.js +40 -0
- package/dist/cjs/index.d.ts +4 -0
- package/dist/cjs/index.js +280 -0
- package/dist/cjs/presentations/fade.d.ts +3 -0
- package/dist/cjs/presentations/flip.d.ts +7 -0
- package/dist/cjs/presentations/slide.d.ts +6 -0
- package/dist/cjs/presentations/wipe.d.ts +6 -0
- package/dist/cjs/slide.js +72 -0
- package/dist/cjs/test/transitions.test.d.ts +1 -0
- package/dist/cjs/timings/linear-timing.d.ts +5 -0
- package/dist/cjs/timings/spring-timing.d.ts +7 -0
- package/dist/cjs/types.d.ts +27 -0
- package/dist/cjs/validate.d.ts +2 -0
- package/dist/cjs/wipe.js +158 -0
- package/package.json +6 -6
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { FC, PropsWithChildren } from 'react';
|
|
2
|
+
import type { LayoutAndStyle, SequencePropsWithoutDuration } from 'remotion';
|
|
3
|
+
import type { TransitionSeriesTransitionProps } from './types.js';
|
|
4
|
+
declare const TransitionSeriesTransition: <PresentationProps extends Record<string, unknown>>(_props: TransitionSeriesTransitionProps<PresentationProps>) => null;
|
|
5
|
+
type SeriesSequenceProps = PropsWithChildren<{
|
|
6
|
+
durationInFrames: number;
|
|
7
|
+
offset?: number;
|
|
8
|
+
className?: number;
|
|
9
|
+
} & LayoutAndStyle & Pick<SequencePropsWithoutDuration, 'name'>>;
|
|
10
|
+
declare const SeriesSequence: ({ children }: SeriesSequenceProps) => JSX.Element;
|
|
11
|
+
declare const TransitionSeries: FC<SequencePropsWithoutDuration> & {
|
|
12
|
+
Sequence: typeof SeriesSequence;
|
|
13
|
+
Transition: typeof TransitionSeriesTransition;
|
|
14
|
+
};
|
|
15
|
+
export { TransitionSeries };
|
package/dist/cjs/fade.js
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
var jsxRuntime = require('react/jsx-runtime');
|
|
6
|
+
var react = require('react');
|
|
7
|
+
var remotion = require('remotion');
|
|
8
|
+
|
|
9
|
+
const FadePresentation = ({ children, presentationDirection, presentationProgress }) => {
|
|
10
|
+
const isEntering = presentationDirection === 'entering';
|
|
11
|
+
const style = react.useMemo(() => {
|
|
12
|
+
return {
|
|
13
|
+
opacity: isEntering ? presentationProgress : 1,
|
|
14
|
+
};
|
|
15
|
+
}, [isEntering, presentationProgress]);
|
|
16
|
+
return (jsxRuntime.jsx(remotion.AbsoluteFill, { children: jsxRuntime.jsx(remotion.AbsoluteFill, { style: style, children: children }) }));
|
|
17
|
+
};
|
|
18
|
+
const fade = (props) => {
|
|
19
|
+
return {
|
|
20
|
+
component: FadePresentation,
|
|
21
|
+
props: props !== null && props !== void 0 ? props : {},
|
|
22
|
+
};
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
exports.fade = fade;
|
package/dist/cjs/flip.js
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
var jsxRuntime = require('react/jsx-runtime');
|
|
6
|
+
var react = require('react');
|
|
7
|
+
var remotion = require('remotion');
|
|
8
|
+
|
|
9
|
+
const Flip = ({ children, presentationDirection, presentationProgress, passedProps: { direction = 'from-left', perspective = 1000 }, }) => {
|
|
10
|
+
const style = react.useMemo(() => {
|
|
11
|
+
const startRotationEntering = direction === 'from-right' || direction === 'from-top' ? 180 : -180;
|
|
12
|
+
const endRotationEntering = direction === 'from-right' || direction === 'from-top' ? -180 : 180;
|
|
13
|
+
const rotation = presentationDirection === 'entering'
|
|
14
|
+
? remotion.interpolate(presentationProgress, [0, 1], [startRotationEntering, 0])
|
|
15
|
+
: remotion.interpolate(presentationProgress, [0, 1], [0, endRotationEntering]);
|
|
16
|
+
const rotateProperty = direction === 'from-top' || direction === 'from-bottom'
|
|
17
|
+
? 'rotateX'
|
|
18
|
+
: 'rotateY';
|
|
19
|
+
return {
|
|
20
|
+
width: '100%',
|
|
21
|
+
height: '100%',
|
|
22
|
+
transform: `${rotateProperty}(${rotation}deg)`,
|
|
23
|
+
backfaceVisibility: 'hidden',
|
|
24
|
+
WebkitBackfaceVisibility: 'hidden',
|
|
25
|
+
};
|
|
26
|
+
}, [direction, presentationDirection, presentationProgress]);
|
|
27
|
+
const outer = react.useMemo(() => {
|
|
28
|
+
return {
|
|
29
|
+
perspective,
|
|
30
|
+
// Make children also their backface hidden
|
|
31
|
+
transformStyle: 'preserve-3d',
|
|
32
|
+
};
|
|
33
|
+
}, [perspective]);
|
|
34
|
+
return (jsxRuntime.jsx(remotion.AbsoluteFill, { style: outer, children: jsxRuntime.jsx(remotion.AbsoluteFill, { style: style, children: children }) }));
|
|
35
|
+
};
|
|
36
|
+
const flip = (props) => {
|
|
37
|
+
return { component: Flip, props: props !== null && props !== void 0 ? props : {} };
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
exports.flip = flip;
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export { linearTiming } from './timings/linear-timing.js';
|
|
2
|
+
export { springTiming } from './timings/spring-timing.js';
|
|
3
|
+
export { TransitionSeries } from './TransitionSeries.js';
|
|
4
|
+
export { TransitionPresentation, TransitionPresentationComponentProps, TransitionTiming, } from './types.js';
|
|
@@ -0,0 +1,280 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
var remotion = require('remotion');
|
|
6
|
+
var jsxRuntime = require('react/jsx-runtime');
|
|
7
|
+
var React = require('react');
|
|
8
|
+
var noReact = require('remotion/no-react');
|
|
9
|
+
|
|
10
|
+
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
11
|
+
|
|
12
|
+
var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
|
|
13
|
+
|
|
14
|
+
const linearTiming = (options) => {
|
|
15
|
+
return {
|
|
16
|
+
getDurationInFrames: () => {
|
|
17
|
+
return options.durationInFrames;
|
|
18
|
+
},
|
|
19
|
+
getProgress: ({ frame }) => {
|
|
20
|
+
return remotion.interpolate(frame, [0, options.durationInFrames], [0, 1], {
|
|
21
|
+
easing: options.easing,
|
|
22
|
+
extrapolateLeft: 'clamp',
|
|
23
|
+
extrapolateRight: 'clamp',
|
|
24
|
+
});
|
|
25
|
+
},
|
|
26
|
+
};
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
const springWithInvalidArgumentRejection = (args) => {
|
|
30
|
+
if (args.to || args.from) {
|
|
31
|
+
throw new Error('to / from values are not supported by springWithRoundUpIfThreshold');
|
|
32
|
+
}
|
|
33
|
+
return remotion.spring(args);
|
|
34
|
+
};
|
|
35
|
+
const springTiming = (options = {}) => {
|
|
36
|
+
return {
|
|
37
|
+
getDurationInFrames: ({ fps }) => {
|
|
38
|
+
if (options.durationInFrames) {
|
|
39
|
+
return options.durationInFrames;
|
|
40
|
+
}
|
|
41
|
+
return remotion.measureSpring({
|
|
42
|
+
config: options.config,
|
|
43
|
+
threshold: options.durationRestThreshold,
|
|
44
|
+
fps,
|
|
45
|
+
});
|
|
46
|
+
},
|
|
47
|
+
getProgress: ({ fps, frame }) => {
|
|
48
|
+
return springWithInvalidArgumentRejection({
|
|
49
|
+
fps,
|
|
50
|
+
frame,
|
|
51
|
+
config: options.config,
|
|
52
|
+
durationInFrames: options.durationInFrames,
|
|
53
|
+
durationRestThreshold: options.durationRestThreshold,
|
|
54
|
+
});
|
|
55
|
+
},
|
|
56
|
+
};
|
|
57
|
+
};
|
|
58
|
+
|
|
59
|
+
const flattenChildren = (children) => {
|
|
60
|
+
const childrenArray = React__default["default"].Children.toArray(children);
|
|
61
|
+
return childrenArray.reduce((flatChildren, child) => {
|
|
62
|
+
if (child.type === React__default["default"].Fragment) {
|
|
63
|
+
return flatChildren.concat(flattenChildren(child.props
|
|
64
|
+
.children));
|
|
65
|
+
}
|
|
66
|
+
flatChildren.push(child);
|
|
67
|
+
return flatChildren;
|
|
68
|
+
}, []);
|
|
69
|
+
};
|
|
70
|
+
|
|
71
|
+
const SlidePresentation = ({ children, presentationProgress, presentationDirection, passedProps: { direction = 'from-left' }, }) => {
|
|
72
|
+
const directionStyle = React.useMemo(() => {
|
|
73
|
+
if (presentationDirection === 'exiting') {
|
|
74
|
+
switch (direction) {
|
|
75
|
+
case 'from-left':
|
|
76
|
+
return {
|
|
77
|
+
transform: `translateX(${presentationProgress * 100}%)`,
|
|
78
|
+
};
|
|
79
|
+
case 'from-right':
|
|
80
|
+
return {
|
|
81
|
+
transform: `translateX(-${presentationProgress * 100}%)`,
|
|
82
|
+
};
|
|
83
|
+
case 'from-top':
|
|
84
|
+
return {
|
|
85
|
+
transform: `translateY(${presentationProgress * 100}%)`,
|
|
86
|
+
};
|
|
87
|
+
case 'from-bottom':
|
|
88
|
+
return {
|
|
89
|
+
transform: `translateY(-${presentationProgress * 100}%)`,
|
|
90
|
+
};
|
|
91
|
+
default:
|
|
92
|
+
throw new Error(`Invalid direction: ${direction}`);
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
switch (direction) {
|
|
96
|
+
case 'from-left':
|
|
97
|
+
return {
|
|
98
|
+
transform: `translateX(${-100 + presentationProgress * 100}%)`,
|
|
99
|
+
};
|
|
100
|
+
case 'from-right':
|
|
101
|
+
return {
|
|
102
|
+
transform: `translateX(${100 - presentationProgress * 100}%)`,
|
|
103
|
+
};
|
|
104
|
+
case 'from-top':
|
|
105
|
+
return {
|
|
106
|
+
transform: `translateY(${-100 + presentationProgress * 100}%)`,
|
|
107
|
+
};
|
|
108
|
+
case 'from-bottom':
|
|
109
|
+
return {
|
|
110
|
+
transform: `translateY(${100 - presentationProgress * 100}%)`,
|
|
111
|
+
};
|
|
112
|
+
default:
|
|
113
|
+
throw new Error(`Invalid direction: ${direction}`);
|
|
114
|
+
}
|
|
115
|
+
}, [presentationDirection, presentationProgress, direction]);
|
|
116
|
+
const style = React.useMemo(() => {
|
|
117
|
+
return {
|
|
118
|
+
width: '100%',
|
|
119
|
+
height: '100%',
|
|
120
|
+
justifyContent: 'center',
|
|
121
|
+
alignItems: 'center',
|
|
122
|
+
...directionStyle,
|
|
123
|
+
};
|
|
124
|
+
}, [directionStyle]);
|
|
125
|
+
return (jsxRuntime.jsx(remotion.AbsoluteFill, { children: jsxRuntime.jsx(remotion.AbsoluteFill, { style: style, children: children }) }));
|
|
126
|
+
};
|
|
127
|
+
const slide = (props) => {
|
|
128
|
+
return {
|
|
129
|
+
component: SlidePresentation,
|
|
130
|
+
props: props !== null && props !== void 0 ? props : {},
|
|
131
|
+
};
|
|
132
|
+
};
|
|
133
|
+
|
|
134
|
+
/* eslint-disable prefer-destructuring */
|
|
135
|
+
const validateDurationInFrames = noReact.NoReactInternals.validateDurationInFrames;
|
|
136
|
+
|
|
137
|
+
// eslint-disable-next-line react/function-component-definition
|
|
138
|
+
const TransitionSeriesTransition = function (
|
|
139
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
140
|
+
_props) {
|
|
141
|
+
return null;
|
|
142
|
+
};
|
|
143
|
+
const SeriesSequence = ({ children }) => {
|
|
144
|
+
// eslint-disable-next-line react/jsx-no-useless-fragment
|
|
145
|
+
return jsxRuntime.jsx(jsxRuntime.Fragment, { children: children });
|
|
146
|
+
};
|
|
147
|
+
const TransitionSeriesChildren = ({ children, }) => {
|
|
148
|
+
const { fps } = remotion.useVideoConfig();
|
|
149
|
+
const frame = remotion.useCurrentFrame();
|
|
150
|
+
const childrenValue = React.useMemo(() => {
|
|
151
|
+
let transitionOffsets = 0;
|
|
152
|
+
let startFrame = 0;
|
|
153
|
+
const flattedChildren = flattenChildren(children);
|
|
154
|
+
return React.Children.map(flattedChildren, (child, i) => {
|
|
155
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j;
|
|
156
|
+
const current = child;
|
|
157
|
+
if (typeof current === 'string') {
|
|
158
|
+
// Don't throw if it's just some accidential whitespace
|
|
159
|
+
if (current.trim() === '') {
|
|
160
|
+
return null;
|
|
161
|
+
}
|
|
162
|
+
throw new TypeError(`The <TransitionSeries /> component only accepts a list of <TransitionSeries.Sequence /> components as its children, but you passed a string "${current}"`);
|
|
163
|
+
}
|
|
164
|
+
const hasPrev = flattedChildren[i - 1];
|
|
165
|
+
const nextPrev = flattedChildren[i + 1];
|
|
166
|
+
const prev = typeof hasPrev === 'string' || typeof hasPrev === 'undefined'
|
|
167
|
+
? null
|
|
168
|
+
: hasPrev.type === TransitionSeriesTransition
|
|
169
|
+
? hasPrev
|
|
170
|
+
: null;
|
|
171
|
+
const next = typeof nextPrev === 'string' || typeof nextPrev === 'undefined'
|
|
172
|
+
? null
|
|
173
|
+
: nextPrev.type === TransitionSeriesTransition
|
|
174
|
+
? nextPrev
|
|
175
|
+
: null;
|
|
176
|
+
const prevIsTransition = typeof hasPrev === 'string' || typeof hasPrev === 'undefined'
|
|
177
|
+
? false
|
|
178
|
+
: hasPrev.type === TransitionSeriesTransition;
|
|
179
|
+
if (current.type === TransitionSeriesTransition) {
|
|
180
|
+
if (prevIsTransition) {
|
|
181
|
+
throw new TypeError(`A <TransitionSeries.Transition /> component must not be followed by another <TransitionSeries.Transition /> component (nth children = ${i - 1} and ${i})`);
|
|
182
|
+
}
|
|
183
|
+
return null;
|
|
184
|
+
}
|
|
185
|
+
if (current.type !== SeriesSequence) {
|
|
186
|
+
throw new TypeError(`The <TransitionSeries /> component only accepts a list of <TransitionSeries.Sequence /> and <TransitionSeries.Transition /> components as its children, but got ${current} instead`);
|
|
187
|
+
}
|
|
188
|
+
const castedChildAgain = current;
|
|
189
|
+
const debugInfo = `index = ${i}, duration = ${castedChildAgain.props.durationInFrames}`;
|
|
190
|
+
if (!(castedChildAgain === null || castedChildAgain === void 0 ? void 0 : castedChildAgain.props.children)) {
|
|
191
|
+
throw new TypeError(`A <TransitionSeries.Sequence /> component (${debugInfo}) was detected to not have any children. Delete it to fix this error.`);
|
|
192
|
+
}
|
|
193
|
+
const durationInFramesProp = castedChildAgain.props.durationInFrames;
|
|
194
|
+
const { durationInFrames, children: _children, ...passedProps } = castedChildAgain.props;
|
|
195
|
+
validateDurationInFrames(durationInFramesProp, {
|
|
196
|
+
component: `of a <TransitionSeries.Sequence /> component`,
|
|
197
|
+
allowFloats: true,
|
|
198
|
+
});
|
|
199
|
+
const offset = (_a = castedChildAgain.props.offset) !== null && _a !== void 0 ? _a : 0;
|
|
200
|
+
if (Number.isNaN(offset)) {
|
|
201
|
+
throw new TypeError(`The "offset" property of a <TransitionSeries.Sequence /> must not be NaN, but got NaN (${debugInfo}).`);
|
|
202
|
+
}
|
|
203
|
+
if (!Number.isFinite(offset)) {
|
|
204
|
+
throw new TypeError(`The "offset" property of a <TransitionSeries.Sequence /> must be finite, but got ${offset} (${debugInfo}).`);
|
|
205
|
+
}
|
|
206
|
+
if (offset % 1 !== 0) {
|
|
207
|
+
throw new TypeError(`The "offset" property of a <TransitionSeries.Sequence /> must be finite, but got ${offset} (${debugInfo}).`);
|
|
208
|
+
}
|
|
209
|
+
const currentStartFrame = startFrame + offset;
|
|
210
|
+
let duration = 0;
|
|
211
|
+
if (prev) {
|
|
212
|
+
duration = prev.props.timing.getDurationInFrames({
|
|
213
|
+
fps,
|
|
214
|
+
});
|
|
215
|
+
transitionOffsets -= duration;
|
|
216
|
+
}
|
|
217
|
+
let actualStartFrame = currentStartFrame + transitionOffsets;
|
|
218
|
+
startFrame += durationInFramesProp + offset;
|
|
219
|
+
// Handle the case where the first item is a transition
|
|
220
|
+
if (actualStartFrame < 0) {
|
|
221
|
+
startFrame -= actualStartFrame;
|
|
222
|
+
actualStartFrame = 0;
|
|
223
|
+
}
|
|
224
|
+
const nextProgress = next
|
|
225
|
+
? next.props.timing.getProgress({
|
|
226
|
+
frame: frame -
|
|
227
|
+
actualStartFrame -
|
|
228
|
+
durationInFrames +
|
|
229
|
+
next.props.timing.getDurationInFrames({ fps }),
|
|
230
|
+
fps,
|
|
231
|
+
})
|
|
232
|
+
: null;
|
|
233
|
+
const prevProgress = prev
|
|
234
|
+
? prev.props.timing.getProgress({
|
|
235
|
+
frame: frame - actualStartFrame,
|
|
236
|
+
fps,
|
|
237
|
+
})
|
|
238
|
+
: null;
|
|
239
|
+
if (next &&
|
|
240
|
+
durationInFramesProp < next.props.timing.getDurationInFrames({ fps })) {
|
|
241
|
+
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})`);
|
|
242
|
+
}
|
|
243
|
+
if (prev &&
|
|
244
|
+
durationInFramesProp < prev.props.timing.getDurationInFrames({ fps })) {
|
|
245
|
+
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})`);
|
|
246
|
+
}
|
|
247
|
+
if (next && prev && nextProgress !== null && prevProgress !== null) {
|
|
248
|
+
const nextPresentation = (_b = next.props.presentation) !== null && _b !== void 0 ? _b : slide();
|
|
249
|
+
const prevPresentation = (_c = prev.props.presentation) !== null && _c !== void 0 ? _c : slide();
|
|
250
|
+
const UppercaseNextPresentation = nextPresentation.component;
|
|
251
|
+
const UppercasePrevPresentation = prevPresentation.component;
|
|
252
|
+
return (jsxRuntime.jsx(remotion.Sequence, { from: Math.floor(actualStartFrame), durationInFrames: durationInFramesProp, layout: "none", showInTimeline: false, children: jsxRuntime.jsx(UppercaseNextPresentation, { passedProps: (_d = nextPresentation.props) !== null && _d !== void 0 ? _d : {}, presentationDirection: "exiting", presentationProgress: nextProgress, children: jsxRuntime.jsx(UppercasePrevPresentation, { passedProps: (_e = prevPresentation.props) !== null && _e !== void 0 ? _e : {}, presentationDirection: "entering", presentationProgress: prevProgress, children: jsxRuntime.jsx(remotion.Sequence, { ...passedProps, children: child }) }) }) }));
|
|
253
|
+
}
|
|
254
|
+
if (prevProgress !== null && prev) {
|
|
255
|
+
const prevPresentation = (_f = prev.props.presentation) !== null && _f !== void 0 ? _f : slide();
|
|
256
|
+
const UppercasePrevPresentation = prevPresentation.component;
|
|
257
|
+
return (jsxRuntime.jsx(remotion.Sequence, { from: Math.floor(actualStartFrame), durationInFrames: durationInFramesProp, layout: "none", showInTimeline: false, children: jsxRuntime.jsx(UppercasePrevPresentation, { passedProps: (_g = prevPresentation.props) !== null && _g !== void 0 ? _g : {}, presentationDirection: "entering", presentationProgress: prevProgress, children: jsxRuntime.jsx(remotion.Sequence, { ...passedProps, children: child }) }) }));
|
|
258
|
+
}
|
|
259
|
+
if (nextProgress !== null && next) {
|
|
260
|
+
const nextPresentation = (_h = next.props.presentation) !== null && _h !== void 0 ? _h : slide();
|
|
261
|
+
const UppercaseNextPresentation = nextPresentation.component;
|
|
262
|
+
return (jsxRuntime.jsx(remotion.Sequence, { from: Math.floor(actualStartFrame), durationInFrames: durationInFramesProp, layout: "none", showInTimeline: false, children: jsxRuntime.jsx(UppercaseNextPresentation, { passedProps: (_j = nextPresentation.props) !== null && _j !== void 0 ? _j : {}, presentationDirection: "exiting", presentationProgress: nextProgress, children: jsxRuntime.jsx(remotion.Sequence, { ...passedProps, children: child }) }) }));
|
|
263
|
+
}
|
|
264
|
+
return (jsxRuntime.jsx(remotion.Sequence, { from: Math.floor(actualStartFrame), durationInFrames: durationInFramesProp, ...passedProps, children: child }));
|
|
265
|
+
});
|
|
266
|
+
}, [children, fps, frame]);
|
|
267
|
+
// eslint-disable-next-line react/jsx-no-useless-fragment
|
|
268
|
+
return jsxRuntime.jsx(jsxRuntime.Fragment, { children: childrenValue });
|
|
269
|
+
};
|
|
270
|
+
const TransitionSeries = ({ children, ...otherProps }) => {
|
|
271
|
+
var _a;
|
|
272
|
+
const showInTimeline = ((_a = otherProps.from) !== null && _a !== void 0 ? _a : 0) !== 0;
|
|
273
|
+
return (jsxRuntime.jsx(remotion.Sequence, { showInTimeline: showInTimeline, ...otherProps, children: jsxRuntime.jsx(TransitionSeriesChildren, { children: children }) }));
|
|
274
|
+
};
|
|
275
|
+
TransitionSeries.Sequence = SeriesSequence;
|
|
276
|
+
TransitionSeries.Transition = TransitionSeriesTransition;
|
|
277
|
+
|
|
278
|
+
exports.TransitionSeries = TransitionSeries;
|
|
279
|
+
exports.linearTiming = linearTiming;
|
|
280
|
+
exports.springTiming = springTiming;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { TransitionPresentation } from '../types.js';
|
|
2
|
+
export type FlipDirection = 'from-left' | 'from-right' | 'from-top' | 'from-bottom';
|
|
3
|
+
export type FlipProps = {
|
|
4
|
+
direction?: FlipDirection;
|
|
5
|
+
perspective?: number;
|
|
6
|
+
};
|
|
7
|
+
export declare const flip: (props?: FlipProps) => TransitionPresentation<FlipProps>;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { TransitionPresentation } from '../types.js';
|
|
2
|
+
export type SlideDirection = 'from-left' | 'from-top' | 'from-right' | 'from-bottom';
|
|
3
|
+
export type SlideProps = {
|
|
4
|
+
direction?: SlideDirection;
|
|
5
|
+
};
|
|
6
|
+
export declare const slide: (props?: SlideProps) => TransitionPresentation<SlideProps>;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { TransitionPresentation } from '../types.js';
|
|
2
|
+
export type WipeDirection = 'from-left' | 'from-top-left' | 'from-top' | 'from-top-right' | 'from-right' | 'from-bottom-right' | 'from-bottom' | 'from-bottom-left';
|
|
3
|
+
export type WipeProps = {
|
|
4
|
+
direction?: WipeDirection;
|
|
5
|
+
};
|
|
6
|
+
export declare const wipe: (props?: WipeProps) => TransitionPresentation<WipeProps>;
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
var jsxRuntime = require('react/jsx-runtime');
|
|
6
|
+
var react = require('react');
|
|
7
|
+
var remotion = require('remotion');
|
|
8
|
+
|
|
9
|
+
const SlidePresentation = ({ children, presentationProgress, presentationDirection, passedProps: { direction = 'from-left' }, }) => {
|
|
10
|
+
const directionStyle = react.useMemo(() => {
|
|
11
|
+
if (presentationDirection === 'exiting') {
|
|
12
|
+
switch (direction) {
|
|
13
|
+
case 'from-left':
|
|
14
|
+
return {
|
|
15
|
+
transform: `translateX(${presentationProgress * 100}%)`,
|
|
16
|
+
};
|
|
17
|
+
case 'from-right':
|
|
18
|
+
return {
|
|
19
|
+
transform: `translateX(-${presentationProgress * 100}%)`,
|
|
20
|
+
};
|
|
21
|
+
case 'from-top':
|
|
22
|
+
return {
|
|
23
|
+
transform: `translateY(${presentationProgress * 100}%)`,
|
|
24
|
+
};
|
|
25
|
+
case 'from-bottom':
|
|
26
|
+
return {
|
|
27
|
+
transform: `translateY(-${presentationProgress * 100}%)`,
|
|
28
|
+
};
|
|
29
|
+
default:
|
|
30
|
+
throw new Error(`Invalid direction: ${direction}`);
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
switch (direction) {
|
|
34
|
+
case 'from-left':
|
|
35
|
+
return {
|
|
36
|
+
transform: `translateX(${-100 + presentationProgress * 100}%)`,
|
|
37
|
+
};
|
|
38
|
+
case 'from-right':
|
|
39
|
+
return {
|
|
40
|
+
transform: `translateX(${100 - presentationProgress * 100}%)`,
|
|
41
|
+
};
|
|
42
|
+
case 'from-top':
|
|
43
|
+
return {
|
|
44
|
+
transform: `translateY(${-100 + presentationProgress * 100}%)`,
|
|
45
|
+
};
|
|
46
|
+
case 'from-bottom':
|
|
47
|
+
return {
|
|
48
|
+
transform: `translateY(${100 - presentationProgress * 100}%)`,
|
|
49
|
+
};
|
|
50
|
+
default:
|
|
51
|
+
throw new Error(`Invalid direction: ${direction}`);
|
|
52
|
+
}
|
|
53
|
+
}, [presentationDirection, presentationProgress, direction]);
|
|
54
|
+
const style = react.useMemo(() => {
|
|
55
|
+
return {
|
|
56
|
+
width: '100%',
|
|
57
|
+
height: '100%',
|
|
58
|
+
justifyContent: 'center',
|
|
59
|
+
alignItems: 'center',
|
|
60
|
+
...directionStyle,
|
|
61
|
+
};
|
|
62
|
+
}, [directionStyle]);
|
|
63
|
+
return (jsxRuntime.jsx(remotion.AbsoluteFill, { children: jsxRuntime.jsx(remotion.AbsoluteFill, { style: style, children: children }) }));
|
|
64
|
+
};
|
|
65
|
+
const slide = (props) => {
|
|
66
|
+
return {
|
|
67
|
+
component: SlidePresentation,
|
|
68
|
+
props: props !== null && props !== void 0 ? props : {},
|
|
69
|
+
};
|
|
70
|
+
};
|
|
71
|
+
|
|
72
|
+
exports.slide = slide;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { SpringConfig } from 'remotion';
|
|
2
|
+
import type { TransitionTiming } from '../types.js';
|
|
3
|
+
export declare const springTiming: (options?: {
|
|
4
|
+
config?: Partial<SpringConfig>;
|
|
5
|
+
durationInFrames?: number;
|
|
6
|
+
durationRestThreshold?: number;
|
|
7
|
+
}) => TransitionTiming;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import type { ComponentType } from 'react';
|
|
2
|
+
export type PresentationDirection = 'entering' | 'exiting';
|
|
3
|
+
export type TransitionTiming = {
|
|
4
|
+
getDurationInFrames: (options: {
|
|
5
|
+
fps: number;
|
|
6
|
+
}) => number;
|
|
7
|
+
getProgress: (options: {
|
|
8
|
+
frame: number;
|
|
9
|
+
fps: number;
|
|
10
|
+
}) => number;
|
|
11
|
+
};
|
|
12
|
+
export type TransitionSeriesTransitionProps<PresentationProps extends Record<string, unknown>> = {
|
|
13
|
+
timing: TransitionTiming;
|
|
14
|
+
presentation?: TransitionPresentation<PresentationProps>;
|
|
15
|
+
};
|
|
16
|
+
type LooseComponentType<T> = ComponentType<T> | ((props: T) => React.ReactNode);
|
|
17
|
+
export type TransitionPresentation<PresentationProps extends Record<string, unknown>> = {
|
|
18
|
+
component: LooseComponentType<TransitionPresentationComponentProps<PresentationProps>>;
|
|
19
|
+
props: PresentationProps;
|
|
20
|
+
};
|
|
21
|
+
export type TransitionPresentationComponentProps<PresentationProps extends Record<string, unknown>> = {
|
|
22
|
+
presentationProgress: number;
|
|
23
|
+
children: React.ReactNode;
|
|
24
|
+
presentationDirection: PresentationDirection;
|
|
25
|
+
passedProps: PresentationProps;
|
|
26
|
+
};
|
|
27
|
+
export {};
|
package/dist/cjs/wipe.js
ADDED
|
@@ -0,0 +1,158 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
var jsxRuntime = require('react/jsx-runtime');
|
|
6
|
+
var react = require('react');
|
|
7
|
+
var remotion = require('remotion');
|
|
8
|
+
|
|
9
|
+
const makePathIn = (progress, direction) => {
|
|
10
|
+
switch (direction) {
|
|
11
|
+
case 'from-left':
|
|
12
|
+
return `
|
|
13
|
+
M 0 0
|
|
14
|
+
L ${progress} 0
|
|
15
|
+
L ${progress} 1
|
|
16
|
+
L 0 1
|
|
17
|
+
Z`;
|
|
18
|
+
case 'from-top-left':
|
|
19
|
+
return `
|
|
20
|
+
M 0 0
|
|
21
|
+
L ${progress * 2} 0
|
|
22
|
+
L 0 ${progress * 2}
|
|
23
|
+
Z`;
|
|
24
|
+
case 'from-top':
|
|
25
|
+
return `
|
|
26
|
+
M 0 0
|
|
27
|
+
L 1 0
|
|
28
|
+
L 1 ${progress}
|
|
29
|
+
L 0 ${progress}
|
|
30
|
+
Z`;
|
|
31
|
+
case 'from-top-right':
|
|
32
|
+
return `
|
|
33
|
+
M 1 0
|
|
34
|
+
L ${1 - progress * 2} 0
|
|
35
|
+
L 1 ${progress * 2}
|
|
36
|
+
Z`;
|
|
37
|
+
case 'from-right':
|
|
38
|
+
return `
|
|
39
|
+
M 1 0
|
|
40
|
+
L 1 1
|
|
41
|
+
L ${1 - progress} 1
|
|
42
|
+
L ${1 - progress} 0
|
|
43
|
+
Z`;
|
|
44
|
+
case 'from-bottom-right':
|
|
45
|
+
return `
|
|
46
|
+
M 1 1
|
|
47
|
+
L ${1 - progress * 2} 1
|
|
48
|
+
L 1 ${1 - progress * 2}
|
|
49
|
+
Z`;
|
|
50
|
+
case 'from-bottom':
|
|
51
|
+
return `
|
|
52
|
+
M 0 1
|
|
53
|
+
L 1 1
|
|
54
|
+
L 1 ${1 - progress}
|
|
55
|
+
L 0 ${1 - progress}
|
|
56
|
+
Z`;
|
|
57
|
+
case 'from-bottom-left':
|
|
58
|
+
return `
|
|
59
|
+
M 0 1
|
|
60
|
+
L 0 ${1 - progress * 2}
|
|
61
|
+
L ${progress * 2} 1
|
|
62
|
+
Z`;
|
|
63
|
+
default:
|
|
64
|
+
throw new Error(`Unknown direction ${JSON.stringify(direction)}`);
|
|
65
|
+
}
|
|
66
|
+
};
|
|
67
|
+
const makePathOut = (progress, direction) => {
|
|
68
|
+
switch (direction) {
|
|
69
|
+
case 'from-left':
|
|
70
|
+
return `
|
|
71
|
+
M 1 1
|
|
72
|
+
L ${1 - progress} 1
|
|
73
|
+
L ${1 - progress} 0
|
|
74
|
+
L 1 0
|
|
75
|
+
Z`;
|
|
76
|
+
case 'from-top-left':
|
|
77
|
+
return `
|
|
78
|
+
M 1 1
|
|
79
|
+
L ${1 - 2 * progress} 1
|
|
80
|
+
L 1 ${1 - 2 * progress}
|
|
81
|
+
Z`;
|
|
82
|
+
case 'from-top':
|
|
83
|
+
return `
|
|
84
|
+
M 1 1
|
|
85
|
+
L 0 1
|
|
86
|
+
L 0 ${1 - progress}
|
|
87
|
+
L 1 ${1 - progress}
|
|
88
|
+
Z`;
|
|
89
|
+
case 'from-top-right':
|
|
90
|
+
return `
|
|
91
|
+
M 0 1
|
|
92
|
+
L ${progress * 2} 1
|
|
93
|
+
L 0 ${1 - progress * 2}
|
|
94
|
+
Z`;
|
|
95
|
+
case 'from-right':
|
|
96
|
+
return `
|
|
97
|
+
M 0 0
|
|
98
|
+
L ${progress} 0
|
|
99
|
+
L ${progress} 1
|
|
100
|
+
L 0 1
|
|
101
|
+
Z`;
|
|
102
|
+
case 'from-bottom-right':
|
|
103
|
+
return `
|
|
104
|
+
M 0 0
|
|
105
|
+
L ${progress * 2} 0
|
|
106
|
+
L 0 ${progress * 2}
|
|
107
|
+
Z`;
|
|
108
|
+
case 'from-bottom':
|
|
109
|
+
return `
|
|
110
|
+
M 1 0
|
|
111
|
+
L 0 0
|
|
112
|
+
L 0 ${progress}
|
|
113
|
+
L 1 ${progress}
|
|
114
|
+
Z`;
|
|
115
|
+
case 'from-bottom-left':
|
|
116
|
+
return `
|
|
117
|
+
M 1 0
|
|
118
|
+
L ${1 - progress * 2} 0
|
|
119
|
+
L 1 ${progress * 2}
|
|
120
|
+
Z`;
|
|
121
|
+
default:
|
|
122
|
+
throw new Error(`Unknown direction ${JSON.stringify(direction)}`);
|
|
123
|
+
}
|
|
124
|
+
};
|
|
125
|
+
const WipePresentation = ({ children, presentationProgress, presentationDirection, passedProps: { direction = 'from-left' }, }) => {
|
|
126
|
+
const [clipId] = react.useState(() => String(remotion.random(null)));
|
|
127
|
+
const progressInDirection = presentationDirection === 'entering'
|
|
128
|
+
? presentationProgress
|
|
129
|
+
: 1 - presentationProgress;
|
|
130
|
+
const path = presentationDirection === 'entering'
|
|
131
|
+
? makePathIn(progressInDirection, direction)
|
|
132
|
+
: makePathOut(progressInDirection, direction);
|
|
133
|
+
const style = react.useMemo(() => {
|
|
134
|
+
return {
|
|
135
|
+
width: '100%',
|
|
136
|
+
height: '100%',
|
|
137
|
+
justifyContent: 'center',
|
|
138
|
+
alignItems: 'center',
|
|
139
|
+
clipPath: `url(#${clipId})`,
|
|
140
|
+
};
|
|
141
|
+
}, [clipId]);
|
|
142
|
+
const svgStyle = react.useMemo(() => {
|
|
143
|
+
return {
|
|
144
|
+
width: '100%',
|
|
145
|
+
height: '100%',
|
|
146
|
+
pointerEvents: 'none',
|
|
147
|
+
};
|
|
148
|
+
}, []);
|
|
149
|
+
return (jsxRuntime.jsxs(remotion.AbsoluteFill, { children: [jsxRuntime.jsx(remotion.AbsoluteFill, { style: style, children: children }), jsxRuntime.jsx(remotion.AbsoluteFill, { children: jsxRuntime.jsx("svg", { viewBox: "0 0 1 1", style: svgStyle, children: jsxRuntime.jsx("defs", { children: jsxRuntime.jsx("clipPath", { id: clipId, clipPathUnits: "objectBoundingBox", children: jsxRuntime.jsx("path", { d: path, fill: "black" }) }) }) }) })] }));
|
|
150
|
+
};
|
|
151
|
+
const wipe = (props) => {
|
|
152
|
+
return {
|
|
153
|
+
component: WipePresentation,
|
|
154
|
+
props: props !== null && props !== void 0 ? props : {},
|
|
155
|
+
};
|
|
156
|
+
};
|
|
157
|
+
|
|
158
|
+
exports.wipe = wipe;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@remotion/transitions",
|
|
3
|
-
"version": "4.0.
|
|
3
|
+
"version": "4.0.136",
|
|
4
4
|
"description": "Transition presets for Remotion",
|
|
5
5
|
"sideEffects": false,
|
|
6
6
|
"main": "dist/esm/index.mjs",
|
|
@@ -16,9 +16,9 @@
|
|
|
16
16
|
"url": "https://github.com/remotion-dev/remotion/issues"
|
|
17
17
|
},
|
|
18
18
|
"dependencies": {
|
|
19
|
-
"remotion": "4.0.
|
|
20
|
-
"@remotion/
|
|
21
|
-
"@remotion/
|
|
19
|
+
"remotion": "4.0.136",
|
|
20
|
+
"@remotion/shapes": "4.0.136",
|
|
21
|
+
"@remotion/paths": "4.0.136"
|
|
22
22
|
},
|
|
23
23
|
"devDependencies": {
|
|
24
24
|
"@jonny/eslint-config": "3.0.276",
|
|
@@ -33,8 +33,8 @@
|
|
|
33
33
|
"@vitejs/plugin-react": "^2.0.0",
|
|
34
34
|
"rollup": "^2.70.1",
|
|
35
35
|
"@rollup/plugin-typescript": "^8.2.0",
|
|
36
|
-
"remotion": "4.0.
|
|
37
|
-
"@remotion/test-utils": "4.0.
|
|
36
|
+
"remotion": "4.0.136",
|
|
37
|
+
"@remotion/test-utils": "4.0.136"
|
|
38
38
|
},
|
|
39
39
|
"peerDependencies": {
|
|
40
40
|
"react": ">=16.8.0",
|