Skip to content

Instantly share code, notes, and snippets.

@perrysmotors
Last active October 9, 2022 08:34
Show Gist options
  • Save perrysmotors/d8438f01548fc28aa30ecb34f9ea8323 to your computer and use it in GitHub Desktop.
Save perrysmotors/d8438f01548fc28aa30ecb34f9ea8323 to your computer and use it in GitHub Desktop.
Smoothly scroll back to the top in Framer X
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