Reputation: 1
I need your help about Reveal.js.
Anyone can explain me how to retrieve the number of my currentslide, and add it into variable ?
I need to add an event on my slide 4.
Thx for the support
Upvotes: 0
Views: 2210
Reputation: 11
I do this to get the indice of the SLide:
Reveal.addEventListener('slidechanged', function (evt) {
ind = Reveal.getIndices().h
if (ind === 0) {
......
}
if (ind === 1) {
.....
}
});
Upvotes: 0
Reputation: 176
You can get the indices of the current slide with Reveal.getIndices()
. It returns an object with three properties:
Now you can compare the current index with the index of the slide you want.
Upvotes: 2
Reputation: 19049
Is this what you meant?
Reveal.addEventListener('slidechanged', function(evt) {
if (evt.currentSlide === 4) {
// Do your stuff
}
});
You can always store currentSlide
somewhere and then retrieve it later if your action requires it to be done in the middle of the presentation, not on slidechanged
.
Upvotes: 0