Skip to content

🎥 Make videos programmatically with React

`@remotion/transiitons/fade`: New `shouldFadeOutExistingScene` option

Jonny Burgere36197d8e3c7
diff --git a/packages/docs/docs/transitions/presentations/fade.mdx b/packages/docs/docs/transitions/presentations/fade.mdx
index c677bfea14..2c95d2d775 100644
--- a/packages/docs/docs/transitions/presentations/fade.mdx
+++ b/packages/docs/docs/transitions/presentations/fade.mdx
@@ -66,6 +66,16 @@ The style of the container element when the scene is is entering.
The style of the container element when the scene is exiting.
+### `shouldFadeOutExitingScene?`<AvailableFrom v="4.0.166"/>
+
+Whether the exiting scene should fade out or not. Default `false`.
+
+:::note
+The default is `false` because if both the entering and existing scene are semi-opaque, the whole scene will be semi-opaque, which will make the content underneath shine though.
+We recommend for transitioning between fully opaque scenes setting this to `false`.
+If the scenes are not fully covered (like fading between overlays), we recommend setting this to `false`.
+:::
+
## See also
- [Source code for this presentation](https://github.com/remotion-dev/remotion/blob/main/packages/transitions/src/presentations/fade.tsx)
diff --git a/packages/transitions/src/presentations/fade.tsx b/packages/transitions/src/presentations/fade.tsx
index 2bca0794e5..b76afbc6c3 100644
--- a/packages/transitions/src/presentations/fade.tsx
+++ b/packages/transitions/src/presentations/fade.tsx
@@ -8,6 +8,7 @@ import type {
export type FadeProps = {
enterStyle?: React.CSSProperties;
exitStyle?: React.CSSProperties;
+ shouldFadeOutExitingScene?: boolean;
};
const FadePresentation: React.FC<
@@ -16,7 +17,11 @@ const FadePresentation: React.FC<
const isEntering = presentationDirection === 'entering';
const style: React.CSSProperties = useMemo(() => {
return {
- opacity: isEntering ? presentationProgress : 1,
+ opacity: isEntering
+ ? presentationProgress
+ : passedProps.shouldFadeOutExitingScene
+ ? 1 - presentationProgress
+ : 1,
...(presentationDirection === 'entering'
? passedProps.enterStyle
: passedProps.exitStyle),
@@ -25,6 +30,7 @@ const FadePresentation: React.FC<
isEntering,
passedProps.enterStyle,
passedProps.exitStyle,
+ passedProps.shouldFadeOutExitingScene,
presentationDirection,
presentationProgress,
]);