Last active
October 9, 2022 08:34
-
-
Save perrysmotors/aa5d5bb7031a69ad17ef7a4ef29554ce to your computer and use it in GitHub Desktop.
Add Parallax to scroll content in Framer X
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
import { Override, motionValue, useTransform } from "framer" | |
const contentOffsetY = motionValue(0) | |
// Apply this override to your scroll component | |
export function TrackScroll(): Override { | |
return { contentOffsetY: contentOffsetY } | |
} | |
// Apply this override to your parallax layer | |
export function ParallaxLayer(): Override { | |
const y = useTransform(contentOffsetY, [0, -100], [0, 50], { | |
clamp: false, | |
}) | |
return { | |
y: y, | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment