remotion 4.0.494 → 4.0.496
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/HtmlInCanvas.js +5 -5
- package/dist/cjs/Img.js +3 -1
- package/dist/cjs/Interactive.d.ts +4 -6
- package/dist/cjs/Interactive.js +46 -37
- package/dist/cjs/Sequence.js +12 -33
- package/dist/cjs/interactivity-schema.d.ts +12 -0
- package/dist/cjs/interactivity-schema.js +10 -3
- package/dist/cjs/internals.d.ts +57 -1
- package/dist/cjs/internals.js +3 -0
- package/dist/cjs/no-react.d.ts +2 -0
- package/dist/cjs/use-current-scale.d.ts +8 -1
- package/dist/cjs/use-current-scale.js +1 -1
- package/dist/cjs/use-premounting.d.ts +19 -0
- package/dist/cjs/use-premounting.js +62 -0
- package/dist/cjs/version.d.ts +1 -1
- package/dist/cjs/version.js +1 -1
- package/dist/esm/index.mjs +293 -224
- package/dist/esm/no-react.mjs +12 -4
- package/dist/esm/version.mjs +1 -1
- package/package.json +2 -2
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.usePremounting = void 0;
|
|
4
|
+
const react_1 = require("react");
|
|
5
|
+
const PremountContext_js_1 = require("./PremountContext.js");
|
|
6
|
+
const use_current_frame_js_1 = require("./use-current-frame.js");
|
|
7
|
+
const use_remotion_environment_js_1 = require("./use-remotion-environment.js");
|
|
8
|
+
const use_video_config_js_1 = require("./use-video-config.js");
|
|
9
|
+
const v5_flag_js_1 = require("./v5-flag.js");
|
|
10
|
+
const usePremounting = ({ from, durationInFrames, premountFor, postmountFor, style, styleWhilePremounted, styleWhilePostmounted, hideWhilePremounted, }) => {
|
|
11
|
+
const parentPremountContext = (0, react_1.useContext)(PremountContext_js_1.PremountContext);
|
|
12
|
+
const frame = (0, use_current_frame_js_1.useCurrentFrame)() - parentPremountContext.premountFramesRemaining;
|
|
13
|
+
const environment = (0, use_remotion_environment_js_1.useRemotionEnvironment)();
|
|
14
|
+
const { fps } = (0, use_video_config_js_1.useVideoConfig)();
|
|
15
|
+
const effectivePremountFor = v5_flag_js_1.ENABLE_V5_BREAKING_CHANGES
|
|
16
|
+
? (premountFor !== null && premountFor !== void 0 ? premountFor : fps)
|
|
17
|
+
: (premountFor !== null && premountFor !== void 0 ? premountFor : 0);
|
|
18
|
+
const effectivePostmountFor = postmountFor !== null && postmountFor !== void 0 ? postmountFor : 0;
|
|
19
|
+
const endThreshold = Math.ceil(from + durationInFrames - 1);
|
|
20
|
+
const premountingActive = !environment.isRendering &&
|
|
21
|
+
frame < from &&
|
|
22
|
+
frame >= from - effectivePremountFor;
|
|
23
|
+
const postmountingActive = !environment.isRendering &&
|
|
24
|
+
frame > endThreshold &&
|
|
25
|
+
frame <= endThreshold + effectivePostmountFor;
|
|
26
|
+
const isPremountingOrPostmounting = premountingActive || postmountingActive;
|
|
27
|
+
const freezeFrame = premountingActive
|
|
28
|
+
? from
|
|
29
|
+
: postmountingActive
|
|
30
|
+
? from + durationInFrames - 1
|
|
31
|
+
: 0;
|
|
32
|
+
const premountingStyle = (0, react_1.useMemo)(() => {
|
|
33
|
+
if (!isPremountingOrPostmounting) {
|
|
34
|
+
return style;
|
|
35
|
+
}
|
|
36
|
+
return {
|
|
37
|
+
...style,
|
|
38
|
+
...(hideWhilePremounted === 'opacity' ? { opacity: 0 } : { display: 'none' }),
|
|
39
|
+
pointerEvents: 'none',
|
|
40
|
+
...(premountingActive ? styleWhilePremounted : {}),
|
|
41
|
+
...(postmountingActive ? styleWhilePostmounted : {}),
|
|
42
|
+
};
|
|
43
|
+
}, [
|
|
44
|
+
isPremountingOrPostmounting,
|
|
45
|
+
hideWhilePremounted,
|
|
46
|
+
postmountingActive,
|
|
47
|
+
premountingActive,
|
|
48
|
+
style,
|
|
49
|
+
styleWhilePostmounted,
|
|
50
|
+
styleWhilePremounted,
|
|
51
|
+
]);
|
|
52
|
+
return {
|
|
53
|
+
effectivePremountFor,
|
|
54
|
+
effectivePostmountFor,
|
|
55
|
+
premountingActive,
|
|
56
|
+
postmountingActive,
|
|
57
|
+
isPremountingOrPostmounting,
|
|
58
|
+
freezeFrame,
|
|
59
|
+
premountingStyle,
|
|
60
|
+
};
|
|
61
|
+
};
|
|
62
|
+
exports.usePremounting = usePremounting;
|
package/dist/cjs/version.d.ts
CHANGED
package/dist/cjs/version.js
CHANGED