Use svelte:element to avoid tag conditions

This commit is contained in:
2022-06-22 23:17:37 +02:00
parent cce0e5d9c2
commit 33487cba5c

View File

@@ -56,28 +56,11 @@
bind:innerWidth bind:innerHeight
/>
{#if tag === 'h1'}
<h1 bind:this={titleEl}
<svelte:element this={tag}
bind:this={titleEl}
class={classes} aria-label={label}
style="--parallax-x: {parallax}%;"
use:reveal={revealOptions}
>
<slot />
</h1>
{:else if tag === 'h2'}
<h2 bind:this={titleEl}
class={classes} aria-label={label}
style="--parallax-x: {parallax}%;"
use:reveal={revealOptions}
>
<slot />
</h2>
{:else if tag === 'p'}
<p bind:this={titleEl}
class={classes} aria-label={label}
style="--parallax-x: {parallax}%;"
use:reveal={revealOptions}
>
<slot />
</p>
{/if}
</svelte:element>