Skip to content

Commit

Permalink
Merge pull request #22 from axmad386/master
Browse files Browse the repository at this point in the history
feat: keyExtractor for custom svelte loop key
  • Loading branch information
Valexr authored Jun 1, 2021
2 parents 1f692f0 + 130ca49 commit d1c66dc
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/Slidy.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import * as action from "./actions.js";
export let slides = [],
keyExtractor=(item,i)=>item.id||i,
wrap = {
id: null,
width: "100%",
Expand Down Expand Up @@ -380,7 +381,7 @@

<ul class="slidy-ul" on:contextmenu={() => (isdrag = false)} style={move()}>
{#if slides}
{#each slides as item, i (item.id)}
{#each slides as item, i (keyExtractor(item,i))}
<li
bind:this={nodes[i]}
data-id={i}
Expand All @@ -395,7 +396,7 @@
{#if slidyinit}
<slot {item}>
{#if slide.backimg === false}
<img alt={item.id} src={item[slide.imgsrckey]} width={item.width} height={item.height} />
<img alt={keyExtractor(item,i)} src={item[slide.imgsrckey]} width={item.width} height={item.height} />
{/if}
</slot>
{/if}
Expand Down

0 comments on commit d1c66dc

Please sign in to comment.