kindoflew / svelte-parallax

a (small) spring-based parallax component library for Svelte
MIT License
145 stars 5 forks source link

[FEATURE]: StickyLayer component #29

Closed kindoflew closed 2 years ago

kindoflew commented 2 years ago

This PR implements a StickyLayer component.

Before reaching its offset.top, the layer will translate as if it was a normal element in the DOM. When it reaches offset.top, it will become "sticky" (actually position: fixed, because CSS hates fun) and will remain that way until the page is scrolled to offset.bottom.

This PR also implements accessing progress in ParallaxLayer using the let directive let:progress -- because I ended up adding that feature to StickyLayer and really liked it in this case (~inspired by~ stolen from #19. thanks @nathancahill! i most likely wouldn't have thought of this without your suggestion.)

I may also end up implementing the let directive for Parallax as well (and maybe get rid of sectionProgress), but I'm having trouble thinking of situations where it'd be useful now that each layer will have its own local progress.

There were also some chores: got rid of cypress snapshots plugin because I never used it and added prettier because I was just using the VS Code extension before and wanted the real thing.