Forum Discussion
How to reset a slide to it's initial state using Javascript
Hi there
I have been trying to implement Dark Mode in my course and have managed to set all the objects / slides the course to switch to their "Dark Mode" states when the timeline starts.
I have also managed to create a custom player tab which toggles the variable "DarkMode" when clicked. Can you get it to also restart the current slide's timeline?
Here is the current code I have which doesn't work after the if statement:
var player = GetPlayer();
let darkMode = player.GetVar("DarkMode");
if (darkMode == true) {
player.SetVar("DarkMode", false);
} else {
player.SetVar("DarkMode", true);
}
var slideNumber = player.GetVar("cpInfoCurrentSlide"); // Get the current slide number
player.GetPlayer().GetSlideById(slideNumber).GetTimeline().StartTimeline("Slide.ElapsedTime");
TIA
Carrie
- WaltHamiltonSuper Hero
From your description. everything you are trying to do can probably be done with triggers. I would try:
Toggle variable DarkMode when user clicks [custom player tab]
Restart timeline on this slide when user clicks [custom player tab]
- CarrieWernhamCommunity Member
Ah! Yes You cannot jump to the same slide BUT you can adjust the timeline on the master slide! I could kiss you! Thank you for your input Walt!
- WaltHamiltonSuper HeroYou're welcome. PIAWYC (Pass it along when you can).