Skip to content

Instantly share code, notes, and snippets.

@perrysmotors
Last active October 9, 2022 08:34
Show Gist options
  • Save perrysmotors/7154f31cf957f8f021d0444af7cab021 to your computer and use it in GitHub Desktop.
Save perrysmotors/7154f31cf957f8f021d0444af7cab021 to your computer and use it in GitHub Desktop.
Transform the height of a layer as you scroll in Framer X
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 app bar
export function AppBar(): Override {
const height = useTransform(contentOffsetY, [0, -52, -52], [140, 88, 88], {
clamp: false,
})
return {
height: height,
}
}
@WLDO
Copy link

WLDO commented Jun 4, 2019

Oh I figured it out. It looks like it doesn't work with the Sticky Scroll component.

@perrysmotors
Copy link
Author

Hey William. It should work fine, and can be used together with my Sticky Headers component from the Framer Store. Here's a demo file. https://www.dropbox.com/s/dagepzjfl1vxxt8/scroll%20interactions%20demo.framerx?dl=0 and take a look at my blog article: https://www.framer.com/blog/posts/mastering-scrolling/
I think I spotted you on Slack so will see if I can help out there...

@WLDO
Copy link

WLDO commented Jun 5, 2019 via email

@perrysmotors
Copy link
Author

I took a look at your file... You had the wrong override applied to the StickyScroll component. You need to use TrackScroll.

@WLDO
Copy link

WLDO commented Jun 5, 2019 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment