Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Automatic transitions #219

Open
firebus opened this issue Oct 20, 2019 · 1 comment
Open

Automatic transitions #219

firebus opened this issue Oct 20, 2019 · 1 comment

Comments

@firebus
Copy link

firebus commented Oct 20, 2019

I'd like the slideshow to run unattended. With the help of https://stackoverflow.com/questions/951021/what-is-the-javascript-version-of-sleep I kludged it in like this in slides.js:

    function sleep (ms) {
        return new Promise(resolve => setTimeout(resolve, ms));
    }

    async function transition(ms) {
        while(1) {
            await sleep(ms);
            console.log('wake up')
            nextSlide();
        }
    }

    // initialize

    (function() {
...
        transition(2000);
    })();
}
@firebus
Copy link
Author

firebus commented Oct 20, 2019

Oh, and I also made nextSlide() wraparound from the last slide to the first:

    var nextSlide = function() {
        if (currentSlideNo < slides.length) {
            currentSlideNo++;
        } else {
            currentSlideNo = 1;
        }
        updateSlideClasses(true);
    };

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

No branches or pull requests

1 participant