block by Rich-Harris 351ec2fc4fcf375d2c8e9090620a8bed

svelte-kit-scroller

Am planning to open source this when I get some breathing room, but a gist will do for now.

Usage:

<Scroller top=0.2 bottom=0.8 threshold=0.5 bind:index bind:offset bind:progress parallax>
  <div slot='background'>
    <!-- fixed, or parallaxing (if the parallax option is set) background -->
  </div>

  <div slot='foreground'>
    <!-- the foreground scrolls normally. As it does, the values of
         `index`, `offset` and `progress` update -->

    <section>
      <!-- typically each section will occupy a decent chunk of vertical space -->
      <p>this is the first section</p>
    </section>

    <section>
      <p>this is the second section</p>
    </section>

    <section>
      <p>this is the third section</p>
    </section>
  </div>
</Scroller>

The options are as follows:

We can listen to the state of the scroller with these bindings:

Scroller.html