0.4.0 • Published 9 months ago

svelte-cooldown v0.4.0

Weekly downloads
-
License
MIT
Repository
github
Last release
9 months ago

Svelte Cooldown

Installation

npm install svelte-cooldown

Usage

<script lang="ts">
  import { createCooldown } from 'svelte-cooldown';

  let cooldown = createCooldown({
    min: 0,
    max: 10,
    duration: 10000,
    autoplay: true,
    allowPause: true,
    oncooldown() {
      /**/
    },
  });
</script>

<div>{cooldown.countdown}</div>
<button onclick={cooldown.start}>
  {#if context.paused}
    Resume
  {:else if context.cooling}
    Pause
  {:else}
    Start
  {/if}
</button>
<button onclick={cooldown.stop}>Stop</button>
<button onclick={cooldown.restart}>Restart</button>

or using the component

<script lang="ts">
  import { Cooldown } from 'svelte-cooldown';
</script>

<Cooldown.Root
  min={0}
  max={10}
  duration={10000}
  autoplay
  allowPause
  oncooldown={function () {
    /**/
  }}
>
  {#snippet children(context)}
    <Cooldown.Countdown />
    <Cooldown.Start>
      {#if context.paused}
        Resume
      {:else if context.cooling}
        Pause
      {:else}
        Start
      {/if}
    </Cooldown.Start>
    <Cooldown.Stop>Stop</Cooldown.Stop>
    <Cooldown.Restart>Restart</Cooldown.Restart>
  {/snippet}
</Cooldown.Root>
0.4.0

9 months ago

0.3.1

10 months ago

0.1.0

1 year ago

0.3.0

12 months ago

0.1.2

1 year ago

0.2.0

1 year ago

0.1.1

1 year ago

0.0.5

1 year ago

0.0.4

1 year ago

0.0.7

1 year ago

0.0.6

1 year ago

0.0.3

1 year ago

0.0.2

1 year ago

0.0.1

1 year ago