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

Get the next slide section from the main slide #2987

Closed
ljfreelancer88 opened this issue Jul 20, 2021 · 5 comments
Closed

Get the next slide section from the main slide #2987

ljfreelancer88 opened this issue Jul 20, 2021 · 5 comments

Comments

@ljfreelancer88
Copy link

ljfreelancer88 commented Jul 20, 2021

Hi, I'm having hard time implementing on how to get the next or upcoming slide section from the main slide.

<div id="slide-current">
  <div class="reveal">
    <div class="slides">
      <section>Slide 1</section>
      <section>Slide 2</section>
      <section>Slide 3</section>
    </div>
  </div>
</div>
<div id="slide-next">
<!-- SHOW THE NEXT SLIDE HERE -->
</div>

I can able to get the current slide using currentSlide. But I didn't see any nextSlide. This is what I have in my mind.

Reveal.on( 'slidechanged', event => {
  // event.currentSlide, event.indexh, event.indexv
  console.log(event.currentSlide);
  document.querySelector('#slide-next').value = event.nextSlide; //nextSlide seems not exist though.
} );

Thank you in advance.

@Martinomagnifico
Copy link
Collaborator

event.currentSlide.nextElementSibling will work. You'll need to rewrite that if the next slide or the current slide is in a vertical stack.

@Sharni17
Copy link

Thank you 😊

@ljfreelancer88
Copy link
Author

event.currentSlide.nextElementSibling will work. You'll need to rewrite that if the next slide or the current slide is in a vertical stack.

Is it possible to get the styling also? Like background image etc.

@Martinomagnifico
Copy link
Collaborator

Martinomagnifico commented Jul 27, 2021

Is it possible to get the styling also? Like background image etc.

You can get any attribute:

event.currentSlide.nextElementSibling.attributes.class
event.currentSlide.nextElementSibling.attributes.style
event.currentSlide.nextElementSibling.getAttribute('data-background-image')

This issue is kind of done. It is more about JavaScript in general than Reveal.js. You can close it now.

@ljfreelancer88
Copy link
Author

Thank you

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

3 participants