Created
May 16, 2019 07:58
-
-
Save didacus/05f47d96d1430e86518b829318be5dc6 to your computer and use it in GitHub Desktop.
Framer X — Parallax
This file contains hidden or 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