Skip to content
This repository has been archived by the owner on May 5, 2022. It is now read-only.

fix: resets interval timer on control click #56

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

kindoflew
Copy link

@kindoflew kindoflew commented Jan 18, 2021

This fixes the second half of #45. I set it up as an action:

<button class="left" on:click={left} use:resetInterval={autoplay} aria-label="left">

...

function resetInterval(node, condition) {
    function handleReset(event) {
        pause();
        resume();
    }

    if(condition) {
        node.addEventListener('click', handleReset);
    }

    return {
        destroy() {
            node.removeEventListener('click', handleReset);
        }
    }
}

REPL Example: https://svelte.dev/repl/a363db348ba4485d965c5b5464428a73?version=3.31.2

I didn't try implementing the first part of the issue (pause on hover) because I noticed that it was a part of the API and I wasn't sure if you wanted it to remain that way or if you'd rather it become a standard feature. If you did want that change I'd be happy to submit another PR for it.

Since this is an "under-the-hood" fix I didn't edit anything in the README. Let me know if anything is off! Thanks!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant