Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Vertical Scroll Lock?

Hey all! I've been working on making a tutorial in Twine, and I'm trying to get it so that when you push a button on the side bar, you can hide/ reveal information in the main body of the page. I've gotten all this set up using passage() links and setting booleans, but this has the annoying effect of scrolling to the top (and also reloading the whole page). I'd like to maintain scroll height, if possible.

I feel like this could be accomplished with a javascript macro that prevents scrolling, or possibly with a Twine macro that does a smart replace, but I don't know javascript, and the Twine macro I was looking at didn't seem to handle replacing text on another passage, or even at another spot on the same passage.

Is there a way, either with javascript or smart replace macros, to prevent the game from scrolling when clicking a button?

Example text of what I'm trying to accomplish below. I want to make it so that clicking the [ ] or [x] won't make the game scroll to the top. (For the example, add a bunch of line breaks at the top to simulate lots of other, bigger, examples.)
<div class="togglebar">
<span class="fancytext">Some Basic Commands</span>
<<if $CPermVar is true>>[[<html>[x]</html>|passage()][$CPermVar = false]]<<else>>[[<html>[ &nbsp;]</html>|passage()][$CPermVar = true]]<<endif>> *create (Create a permanent variable)
</div>

<div class = "exampletext">
<<if $CPermVar is true>>
 *create Spooky false
 This creates the variable Spooky and sets it false. The create command must be used in the scene "setup".
<<endif>>
<</div>>

Thanks so much! And I'm using Twine 1.4.2 Sugarcane.
Sign In or Register to comment.