Last active
October 9, 2022 08:34
-
-
Save perrysmotors/d8438f01548fc28aa30ecb34f9ea8323 to your computer and use it in GitHub Desktop.
Smoothly scroll back to the top in Framer X
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, useAnimation } from "framer" | |
// Declare the controls variable so we can access it from both functions | |
let controls | |
// Apply this override to your scroll component | |
export function Scroll(): Override { | |
controls = useAnimation() | |
return { scrollAnimate: controls } | |
} | |
// Apply this override to your buton | |
export function Button(): Override { | |
return { | |
onTap: () => controls.start({ y: 0 }), | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment