Force a scroll to the top.

Hi there!

When it comes to particularly long scenes or dialogues without branching choices, I've typically had to resort to cutting things down to smaller lots of paragraphs so that people playing don't have to scroll all the way back up to the top, having the final bit of text thrust at them before they've even started reading.

I do this with 'press any key to continue' checks, but I've never really been satisfied with that, especially as I design games without text input, and that function is connected to that box, which means I have to turn it on, do the pause, then turn it off immediately every time.

I was wondering if there's a way I could just force the scroll back up to the top when the text is dropped, bearing in mind I clear the screen on pretty much every turn. Alternately, is there a way to stop the auto-scroll down altogether?

Nevermind --- if you're clearing the screen after your waits...that was my suggestion.


My current system is scenes chopped up into portions, separated by wait checks. I don't tend to clear the screen after these, as I'd have no reason to - the clearing comes after the scene is concluded.

Ideally, I'd like to be able to cut out having to raise the command bar, wait check, hide the command bar every single time, along with having to chop things up in the first place, but the auto scroll buggers that up.

There is a "scroll to top" command...
I'm just not sure what it would be.
Unfortunally... the docs is mainly a list of commands, very few explanations or examples.

You can disable the auto-scroll easily enough. Just override the javascript function scrollToEnd()

JS.eval ("scrollToEnd = function () {}")

this will disable all automatic scrolling.

Or here's an alternate version which will stop the text from scrolling more than a page at a time (off the top of my head, a first guess. If this doesn't work, maybe it'll give someone more familiar with the system some ideas):

$(function () {
  var isScrolling = 0;
  scrollToEnd = function () {
    if (!isScrolling) {
      var endOfPage = $("#gameContent").scrollHeight();
      var currentPosition = Math.max($("body").scrollTop(), $("html").scrollTop());
      var maxScroll = currentPosition + 0.9 * ($(window).height() - $("#gamePanelSpacer").height() - $("#txtCommandDiv").height());
      scrollTo = Math.min (endOfPage - $(window).height(), maxScroll);
      if (scrollTo > currentPosition) {
        $("html,body").animate({scrollTop: scrollTo}, {always: function () {
          isScrolling = 0;

Or in a Quest-wrapped form:

JS.eval("$(function(){var n=0;scrollToEnd=function(){if(!n){var o=$('#gameContent').scrollHeight(),l=Math.max($('body').scrollTop(),$('html').scrollTop()),t=l+.9*($(window).height()-$('#gamePanelSpacer').height()-$('#txtCommandDiv').height());scrollTo=Math.min(o-$(window).height(),t),scrollTo>l&&(n++,$('html,body').animate({scrollTop:scrollTo},{always:function(){n=0}}))}}});")

You're an angel, angel.

JS.eval ("scrollToEnd = function () {}")

Works just dandy for my purposes! Better idea that forcing a scroll to the top, for sure. Cheers!



I've been having the same problem. I never even dreamed there was a solution to it! Thank you so much!

This topic is now closed. Topics are closed after 60 days of inactivity.