-
Notifications
You must be signed in to change notification settings - Fork 30
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
164 additions
and
117 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
67 changes: 34 additions & 33 deletions
67
remotion/compositions/templates/carousel/Carousel.composition.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,38 +1,39 @@ | ||
import { Composition, Folder, staticFile } from 'remotion' | ||
import {Composition, Folder, staticFile} from 'remotion'; | ||
|
||
import { Carousel } from './Carousel' | ||
import {Carousel} from './Carousel'; | ||
|
||
export const CarouselComposition: React.FC = () => { | ||
const imageUrls = [ | ||
'https://secure.meetupstatic.com/photos/event/a/9/9/9/highres_511003417.webp', | ||
'https://secure.meetupstatic.com/photos/event/4/a/c/7/highres_515299143.webp', | ||
'https://secure.meetupstatic.com/photos/event/a/8/1/1/highres_515983025.webp', | ||
'https://secure.meetupstatic.com/photos/event/a/8/0/b/highres_515983019.webp', | ||
] | ||
const imageUrls = [ | ||
'https://secure.meetupstatic.com/photos/event/a/9/9/9/highres_511003417.webp', | ||
'https://secure.meetupstatic.com/photos/event/4/a/c/7/highres_515299143.webp', | ||
'https://secure.meetupstatic.com/photos/event/a/8/1/1/highres_515983025.webp', | ||
'https://secure.meetupstatic.com/photos/event/a/8/0/b/highres_515983019.webp', | ||
]; | ||
|
||
const imageDuration = 90 | ||
const imageDuration = 90; | ||
|
||
return ( | ||
<Folder name="Carousel"> | ||
<Composition | ||
component={Carousel} | ||
width={800} | ||
height={800} | ||
id="Carousel" | ||
fps={30} | ||
durationInFrames={imageUrls.length * imageDuration} | ||
defaultProps={{ | ||
imageUrls, | ||
imageDuration, | ||
logoUrl: staticFile('/images/showcases/lyonjs/lyonjsSquaredLogo.png') | ||
}} | ||
calculateMetadata={(props)=> { | ||
|
||
return { | ||
durationInFrames: props.defaultProps.imageDuration * props.defaultProps.imageUrls.length | ||
} | ||
}} | ||
/> | ||
</Folder> | ||
); | ||
}; | ||
return ( | ||
<Folder name="Carousel"> | ||
<Composition | ||
component={Carousel} | ||
width={800} | ||
height={800} | ||
id="Carousel" | ||
fps={30} | ||
durationInFrames={imageUrls.length * imageDuration} | ||
defaultProps={{ | ||
imageUrls, | ||
imageDuration, | ||
logoUrl: staticFile('/images/showcases/lyonjs/lyonjsSquaredLogo.png'), | ||
}} | ||
calculateMetadata={(props) => { | ||
return { | ||
durationInFrames: | ||
props.defaultProps.imageDuration * | ||
props.defaultProps.imageUrls.length, | ||
}; | ||
}} | ||
/> | ||
</Folder> | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,23 +1,46 @@ | ||
import { AbsoluteFill, Img, Sequence } from 'remotion' | ||
import {AbsoluteFill, Img, Sequence} from 'remotion'; | ||
|
||
import { CarouselImage } from './CarouselImage' | ||
import {CarouselImage} from './CarouselImage'; | ||
|
||
export type CarouselType = { | ||
imageUrls: string[] | ||
logoUrl?: string | ||
imageDuration: number | ||
} | ||
export function Carousel({ imageUrls, logoUrl, imageDuration }: CarouselType) { | ||
const delayShift = imageDuration * 0.25; | ||
imageUrls: string[]; | ||
logoUrl?: string; | ||
imageDuration: number; | ||
}; | ||
export function Carousel({imageUrls, logoUrl, imageDuration}: CarouselType) { | ||
const delayShift = imageDuration * 0.25; | ||
|
||
return <AbsoluteFill style={{ overflow: 'hidden', background: 'black'}}> | ||
{ | ||
imageUrls.map((image, index) => { | ||
return <Sequence from={index * (imageDuration - delayShift)} key={image} durationInFrames={index === imageUrls.length - 1? undefined: imageDuration} name={`Image number ${index}`}> | ||
<CarouselImage imageUrl={image} noAnimation={index === imageUrls.length - 1} imageDuration={imageDuration}/> | ||
</Sequence> | ||
}) | ||
} | ||
{logoUrl && <Img src={logoUrl} style={{ position: 'absolute', right: '20px', bottom: '20px', height: "100px"}}/>} | ||
</AbsoluteFill> | ||
} | ||
return ( | ||
<AbsoluteFill style={{overflow: 'hidden', background: 'black'}}> | ||
{imageUrls.map((image, index) => { | ||
return ( | ||
<Sequence | ||
from={index * (imageDuration - delayShift)} | ||
key={image} | ||
durationInFrames={ | ||
index === imageUrls.length - 1 ? undefined : imageDuration | ||
} | ||
name={`Image number ${index}`} | ||
> | ||
<CarouselImage | ||
imageUrl={image} | ||
noAnimation={index === imageUrls.length - 1} | ||
imageDuration={imageDuration} | ||
/> | ||
</Sequence> | ||
); | ||
})} | ||
{logoUrl && ( | ||
<Img | ||
src={logoUrl} | ||
style={{ | ||
position: 'absolute', | ||
right: '20px', | ||
bottom: '20px', | ||
height: '100px', | ||
}} | ||
/> | ||
)} | ||
</AbsoluteFill> | ||
); | ||
} |
120 changes: 75 additions & 45 deletions
120
remotion/compositions/templates/carousel/CarouselImage.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,49 +1,79 @@ | ||
import { CSSProperties } from 'react' | ||
import { Easing, Img, interpolate, useCurrentFrame, useVideoConfig } from 'remotion' | ||
import {CSSProperties} from 'react'; | ||
import { | ||
Easing, | ||
Img, | ||
interpolate, | ||
useCurrentFrame, | ||
useVideoConfig, | ||
} from 'remotion'; | ||
|
||
export type AnimationMode = 'slideLeft' | ||
export function CarouselImage({ imageUrl, imageDuration, noAnimation = false }: { imageUrl: string, imageDuration: number, noAnimation?: boolean}) { | ||
const frame = useCurrentFrame(); | ||
const { width } = useVideoConfig(); | ||
const animationDuration = imageDuration * 0.10; | ||
const slide = interpolate(frame, [imageDuration - animationDuration , imageDuration], [0,width/2], { | ||
easing: Easing.out(Easing.cubic), | ||
extrapolateRight: 'clamp' | ||
}) | ||
const opacity = interpolate(frame, [imageDuration - animationDuration , imageDuration], [1,0], { | ||
extrapolateRight: 'clamp' | ||
}) | ||
export type AnimationMode = 'slideLeft'; | ||
export function CarouselImage({ | ||
imageUrl, | ||
imageDuration, | ||
noAnimation = false, | ||
}: { | ||
imageUrl: string; | ||
imageDuration: number; | ||
noAnimation?: boolean; | ||
}) { | ||
const frame = useCurrentFrame(); | ||
const {width} = useVideoConfig(); | ||
const animationDuration = imageDuration * 0.1; | ||
const slide = interpolate( | ||
frame, | ||
[imageDuration - animationDuration, imageDuration], | ||
[0, width / 2], | ||
{ | ||
easing: Easing.out(Easing.cubic), | ||
extrapolateRight: 'clamp', | ||
}, | ||
); | ||
const opacity = interpolate( | ||
frame, | ||
[imageDuration - animationDuration, imageDuration], | ||
[1, 0], | ||
{ | ||
extrapolateRight: 'clamp', | ||
}, | ||
); | ||
|
||
let animation: CSSProperties = { | ||
transform: `translate(-${slide}px)`, | ||
opacity, | ||
}; | ||
|
||
let animation: CSSProperties = { | ||
transform: `translate(-${slide}px)`, | ||
opacity, | ||
} | ||
if (noAnimation) { | ||
animation = {}; | ||
} | ||
|
||
if(noAnimation) { | ||
animation = {} | ||
} | ||
|
||
return <> | ||
<Img src={imageUrl} style={{ | ||
position: 'absolute', | ||
inset: 0, | ||
objectFit: 'cover', | ||
width: '100%', | ||
height: '100%', | ||
filter: 'blur(20px)', | ||
transform: 'scale(1.2)', | ||
opacity: 0.3, | ||
...animation | ||
}}/> | ||
<Img src={imageUrl} style={{ | ||
position: 'absolute', | ||
inset: 0, | ||
objectFit: 'contain', | ||
width: '100%', | ||
height: '100%', | ||
...animation | ||
}}/> | ||
</> | ||
|
||
} | ||
return ( | ||
<> | ||
<Img | ||
src={imageUrl} | ||
style={{ | ||
position: 'absolute', | ||
inset: 0, | ||
objectFit: 'cover', | ||
width: '100%', | ||
height: '100%', | ||
filter: 'blur(20px)', | ||
transform: 'scale(1.2)', | ||
opacity: 0.3, | ||
...animation, | ||
}} | ||
/> | ||
<Img | ||
src={imageUrl} | ||
style={{ | ||
position: 'absolute', | ||
inset: 0, | ||
objectFit: 'contain', | ||
width: '100%', | ||
height: '100%', | ||
...animation, | ||
}} | ||
/> | ||
</> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters