Skip to content

🎥 Make videos programmatically with React

cool

Jonny Burgeradec5399e6e4
diff --git a/packages/docs/src/remotion/HomepageVideo/Card.tsx b/packages/docs/src/remotion/HomepageVideo/Card.tsx
index 04e4033225..26e85836b3 100644
--- a/packages/docs/src/remotion/HomepageVideo/Card.tsx
+++ b/packages/docs/src/remotion/HomepageVideo/Card.tsx
@@ -72,7 +72,8 @@ const Card: React.FC<{
const refToUse = refsToUse[index];
const stopPrevious = useRef<(() => void)[]>([]);
- let newIndices = null;
+ // eslint-disable-next-line react-hooks/exhaustive-deps
+ let newIndices = [...indices];
const applyPositions = useCallback(
(except: number | null) => {
@@ -109,12 +110,13 @@ const Card: React.FC<{
}
const progress = spring({
- fps: 30,
+ fps: 60,
frame: animationI,
config: {
damping: 200,
},
- durationRestThreshold: 0.01,
+ durationInFrames: duration,
+ durationRestThreshold: 0.001,
});
const newX =
progress * (shouldBe.x - releasePositionX) + releasePositionX;
@@ -131,6 +133,7 @@ const Card: React.FC<{
refsToUse.forEach((r) => {
r.current.style.zIndex = "1";
r.current.classList.remove(styles.active);
+ r.current.classList.remove(styles.passive);
});
if (i === 0) {
setTimeout(() => {
@@ -161,6 +164,11 @@ const Card: React.FC<{
let translateX = 0;
let translateY = 0;
const onMove = (evt: PointerEvent) => {
+ refsToUse.forEach((r) => {
+ if (r !== refToUse) {
+ r.current.classList.add(styles.passive);
+ }
+ });
refToUse.current.classList.add(styles.active);
const scale =
refToUse.current.getBoundingClientRect().width / cardWidth;
@@ -234,17 +242,25 @@ const Card: React.FC<{
onPointerDown={onPointerDown}
onPointerUp={onPointerUp}
style={{
- backgroundColor: "#eee",
- borderRadius: 13,
width: cardWidth,
height: cardHeight,
position: "absolute",
left: x,
top: y,
userSelect: "none",
+ border: "1px solid #eee",
+ borderRadius: 13,
}}
>
- {content}
+ <AbsoluteFill
+ style={{
+ backgroundColor: "#eee",
+ borderRadius: 13,
+ }}
+ className={styles.content}
+ >
+ {content}
+ </AbsoluteFill>
</div>
);
};
diff --git a/packages/docs/src/remotion/HomepageVideo/player-styles.module.css b/packages/docs/src/remotion/HomepageVideo/player-styles.module.css
index 31c046a9a3..1c9f8ea4cb 100644
--- a/packages/docs/src/remotion/HomepageVideo/player-styles.module.css
+++ b/packages/docs/src/remotion/HomepageVideo/player-styles.module.css
@@ -3,6 +3,14 @@
transition: scale 0.2s ease;
}
+.content {
+ transition: opacity 0.2s ease;
+}
+
+.passive .content {
+ opacity: 0.6;
+}
+
.active {
scale: 1.05;
}