sveltejs / svelte-scroller

A <Scroller> component for Svelte apps
https://svelte.dev/repl/76846b7ae27b3a21becb64ffd6e9d4a6
Other
347 stars 25 forks source link

Dynamic data not working #10

Open MarcWadai opened 4 years ago

MarcWadai commented 4 years ago

When clicking on a button the data from my scroller are updating. But even by updating the index and count. The scroller information are going to stay the same. Is there a way to use the scroller with information that update in time ? Here are an example of my code :

The data that is updating below is the array myPhotos

<Scroller
  top={0.2}
  bottom={0.8}
  bind:index
  bind:offset
  bind:progress
  bind:count>
  <div slot="background">
    <div
      class={index % 2 == 0 ? 'background_wrapper-left' : 'background_wrapper-right'}>
      <div class="background_content" out:fade>
        {#if myPhotos && myPhotos[index]}
          <p>{myPhotos[index].description}</p>
        {/if}
      </div>
    </div>
  </div>

  <div slot="foreground">
    {#each myPhotos as item}
      <section>
        <div class="m_picture">
          {#if visible && myPhotos[index] && myPhotos[index].name == item.name}
            <div class="m_picture-title">
              <span>{item.title}</span>
              <span>{item.location}</span>
            </div>
          {/if}
        </div>
      </section>
    {/each}
  </div>
</Scroller>