svelte-cooldown
TypeScript icon, indicating that this package has built-in type declarations

0.0.7 • Public • Published

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,
    oncooldown() {
      /**/
    },
  });
</script>

<div>{cooldown.countdown}</div>

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

or using the component

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

<Cooldown
  min={0}
  max={10}
  duration={10000}
  autoplay
  oncooldown={function () {
    /**/
  }}
>
  {#snippet children(context)}
    <div>{context.countdown}</div>

    <button onclick={context.start}>Start</button>
    <button onclick={context.stop}>Stop</button>
    <button onclick={context.restart}>Restart</button>
    <button onclick={context.pause}>
      {#if context.paused}
        Resume
      {:else}
        Pause
      {/if}
    </button>
  {/snippet}
</Cooldown>

Package Sidebar

Install

npm i svelte-cooldown

Weekly Downloads

10

Version

0.0.7

License

MIT

Unpacked Size

6.72 kB

Total Files

12

Last publish

Collaborators

  • calvojp