Custom scripts for ultimate extensibility

Slipshow can execute a custom script (written in JavaScript) at any step of a presentation.

Editor
Presentation
Both

    

This is great! Include any JavaScript you want in a Slipshow, for instance for your animations, simulation, etc.

However, there is a catch. What happens when you “go back” to a step before the execution of the script? How can you undo all the side effects that happened, to go back to the previous step? Try to go back in the example above: it does not undo the scripted effect!

Slipshow needs a bit more information. It needs to be provided with the “reverse” of the execution of the script. And indeed, that is one way: just return the function to undo the script, wrapped in an object.

Editor
Presentation
Both

    

That’s a start, but it is not always easy to write a script to undo the changes. Consider for example if we change the background of multiple elements, and they all have different initial backgrounds.

Editor
Presentation
Both

    

This is wrong: when we go back, we have lost the original element backgrounds.

Slipshow provides an API for such cases. For instance, slip.setStyle allows setting the style of an element, while recording the changes needed to invert them when the moment comes. When using this approach, it’s not necessary to return an “undo” function; it will be inferred by Slipshow through the API calls.

Editor
Presentation
Both

    

That’s all there is to it! An easy to write script that allows Slipshow to undo its changes! The API available via slip allows more than just setting styles. You can find the full API in the reference. If you want to do something that is not in the API, you have an escape hatch! The function slip.onUndo allows you to register your own undo function, for instance:

Editor
Presentation
Both