Join Justin Putney for an in-depth discussion in this video Solution: Creating a loop, part of HTML5 Projects: Creating an Advanced Responsive Presentation.
- View Offline
Alright, now we can take a look at what I came up with.…This is in the Chapter 3 folder of the exercise files under 04_Solution in the…final folder, and I'm going to go to the js folder and open up pres.js.…So, at the top I just created a variable called loop and set it to true.…And then if you scroll down to the go to function.…So, what I did here was to take the existing functionality and just wrap it in…an else clause. So, this is the code that says, you know,…that makes sure that we stay within the first screen and within the last screen,…of course. And if that's true, we set the…currentSlide and we move on from there. And if that isn't true, it just kind of…fails and exits the function. So that's in an else clause.…
And now we have this if clause, and that runs if we have loops set to true.…So if loop is set to true, and we happen to go below zero, well then we just…want to go to the last slide, so essentially we're on the first screen,…we're going backwards. We just want to make sure currentSlide…
Need more information on creating an initial web presentation? Watch the related HTML5 Projects: Creating a Responsive Presentation course.
- Embedding a Twitter feed in an iframe
- Creating the code for automatic playback
- Using MediaElement.js in your presentation
- Adding video and audio