Skip to content

Instantly share code, notes, and snippets.

@JoshuaGrams
Last active February 4, 2026 05:47
Show Gist options
  • Select an option

  • Save JoshuaGrams/2e5d3029dc48edf8770abb4a6b682ff2 to your computer and use it in GitHub Desktop.

Select an option

Save JoshuaGrams/2e5d3029dc48edf8770abb4a6b682ff2 to your computer and use it in GitHub Desktop.
Line-by-line text reveal: Twine/SugarCube.
This will show at the start.
@@.hide;This will show after you click or press space/enter.@@
@@.hide;This will show after you advance again.@@
@@.hide;And again...@@
.hide { display: none; }
function revealFirstHidden(ev) {
if(ev.target.nodeName === 'A') return
const hidden = $('.passage .hide')
if(hidden.length > 0) {
let show = hidden.first()
show.removeClass('hide')
if(show[0].scrollIntoView)
show[0].scrollIntoView({behavior: 'smooth', block: 'nearest'})
}
}
const continueKeys = { " ": true, Enter: true }
$(document).ready(function() {
$('html').on('click', revealFirstHidden)
$('html').on('keypress', function(ev) {
if(continueKeys[ev.key] && !(ev.ctrlKey || ev.altKey || ev.shiftKey)) {
revealFirstHidden(ev)
}
})
})
@cosmonautdad
Copy link
Copy Markdown

hello ! love this , but the continue marker still haunts me whenever i'm adding more than one reveal

@JoshuaGrams
Copy link
Copy Markdown
Author

Sorry, I'm not sure what you're saying. The continue marker doesn't go away when you reveal the last one?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment