I want to show the credits of my game in a smoothly moving movie-captions style. I found several pure javascript variants, but was unable to adapt them to Twine. Neither I can get the size of the window (document.body.clientHeight returns 0!) nor I can access the div containing the moving text. E.g.:
<div id="capts"> <span><center><b>Game Title</b>
Author: Author
Music: Musician
2016
</center></span></div>
document.getElementById("capts") returns null!
Comments
You need to issue your two document related calls after the passage contents has been displayed to the Reader, that way the #capts div element will exist and the height of the client will be calculated.
Unfortunately Sugarcane does not have SugarCube's postdisplay event, so you will have to use a setTimeout() function call to delay the execution of the javascript code you want to use.
There are a number of different ways you can call the setTimeout function, two of them being:
1. In a postrender event:
2. Via a <<set>> macro call in the Credits passage:
You did not include links to the movie-captions style javascript you wanted to run.
This is the resulting code: It also requires the stylesheet:
BTW, I wrote one more nice function based on the previous idea. It fades out the final passage, then goes to credits: