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

Using the API methods in Vanilla JS #771

Open
CedricEggenspiller opened this issue Nov 28, 2019 · 2 comments
Open

Using the API methods in Vanilla JS #771

CedricEggenspiller opened this issue Nov 28, 2019 · 2 comments

Comments

@CedricEggenspiller
Copy link

Hi, thanks for this plugin.
I'd like to make the slideshow run automatically. I wanted to use the .next() method with a timeout but I'm unable to make the equivalent of JQuery data() (like in your example : $elements.data().lory.next();) in vanilla JS. Any idea? And maybe that could be a future improvement to have an auto slideshow option.

Thank you !

Cédric

@longdoan7421
Copy link

You could use something like this:

var el = document.getElementById('#slider');
var slider = lory(el, options);
var timeout;
var triggerAutoSlide = function () {
    timeout = setTimeout(function () {
         slider.next();
    }, 300 + 3000); // transition time + delay time
}
triggerAutoSlide(); // trigger after init
el.addEventListener('after.lory.slide', function () {
    clearTimeout(timeout);
    triggerAutoSlide();
});

@CedricEggenspiller
Copy link
Author

CedricEggenspiller commented Mar 20, 2020 via email

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

2 participants