Scroll Trigger Animations
Scroll triggerd animations never been easier, now you can animate transforms, and roundness and positioning.
Combo animations (inset on x axis, scale and translateY)
This demo is inspired by Beyond agency hero section.
Installation
Usage
<ContainerScrollAnimation className="overflow-hidden">
<ContainerScrollTranslate className="h-dvh relative">
<ContainerScrollInset className="h-full relative">
<ContainerScrollScale className="flex bg-secondary gap-2 overflow-hidden px-6">
<ContainerScrollTranslate
yRange={['0%', '-10%']}
className="flex flex-col gap-2"
>
{IMAGES_1.map((imageUrl, index) => (
<img
key={index}
className="aspect-[4/2.5] inline-block align-middle h-auto max-h-full w-full object-cover"
src={imageUrl}
alt="gallery item"
/>
))}
</ContainerScrollTranslate>
<ContainerScrollTranslate
yRange={['0%', '20%']}
className="flex mt-[-20%] relative flex-col gap-2"
>
{IMAGES_2.map((imageUrl, index) => (
<img
key={index}
className="aspect-[4/2.5] inline-block align-middle h-auto max-h-full w-full object-cover"
src={imageUrl}
alt="gallery item"
/>
))}
</ContainerScrollTranslate>
<ContainerScrollTranslate
yRange={['0%', '-10%']}
className="hidden md:flex flex-col gap-2"
>
{IMAGES_3.map((imageUrl, index) => (
<img
key={index}
className="aspect-[4/2.5] inline-block align-middle h-auto max-h-full w-full object-cover"
src={imageUrl}
alt="gallery item"
/>
))}
</ContainerScrollTranslate>
</ContainerScrollScale>
</ContainerScrollInset>
</ContainerScrollTranslate>
</ContainerScrollAnimation>
Examples
Inset with roundness
Inset-X
Inset-Y
Roundness
Scale
Props
ContainerScrollAnimation
Prop | Type | Default |
---|---|---|
spacerClass? | string | - |
ContainerScrollTranslate
Prop | Type | Default |
---|---|---|
yRange? | number[] | [0, 384] |
inputRange? | number[] | [0, 1] |
ContainerScrollInset
Prop | Type | Default |
---|---|---|
insetRange? | number[] | [48, 0] |
inputRange? | number[] | [0, 1] |
ContainerScrollScale
Prop | Type | Default |
---|---|---|
yRange? | number[] | [1.2, 1] |
inputRange? | number[] | [0, 1] |