Howdy, Stranger!

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

Harlowe bug: A tall page following a tall page won't scroll back to the top

edited December 2014 in Help! with 2.0
If a link at the bottom of a very tall page links to another very tall page, the screen won't scroll back to the top of the 2nd page when clicking the link.

How to reproduce:
1) Create a very tall page with enough line breaks so that it's tall enough to be higher than your screen height.
2) Put a link at the bottom of that page that links to a second page.
3) Edit the 2nd page so that it is also very tall (taller than your screen)
4) Play from the 1st page
5) Click the link at the bottom of the page

Result:
When the 2nd page is displayed, the page doesn't scroll back to the top. This can cause the reader to miss the text above.

See the attached file for an example.

Comments

  • While waiting for this bug to be fixed, is there a workaround I could use?

    I tried to put some javascript in my passage that would scroll to the top of the page:

    <script>
    function scrollWin() {
    window.scrollTo(0, 0);
    }
    </script>
    ...but that doesn't work. It just print all that code into my story, like it's regular text.

    Maybe I could put something in the "Edit Story Javascript" window? How would I catch the event "passage is loaded"?

    Actually, how do I write code into the Edit Story Javascript window? I tried to put simple stuff like "console.log("lorem ipsum") or "alert("toto");" but it doesn't do anything.
  • Currently the version of Harlowe that comes with Twine 2 ignores the Stylesheet and Javascript special passages, they are included in the generated HTML but are not processed by the javascript engine. You can download and manually install the latest version of Harlowe (which I believe is fixed) from its Bitbucket site.
  • How would I do that? I don't know which file to get and how to install/use it.
  • How to manually update your local version of the Harlowe story format is briefly talked about in this thread.

    It is not a straight forward process and relies on the user knowing a little about what they are doing but it starts with downloading the latest version of Harlowe from here.
  • Wow, that looks complicated. I expected to simply have to copy 1 file like I used to in the old Twine 1.0.

    Back to my original problem, how could I make the page scroll back to the top after each passage is loaded? Right now, this prevents me from releasing my story, because my players simply don't see that there's text above, and they miss half the text.

    I tried to write javascript code in the passages themselves, but the code doesn't seem to be executed. Is it also related to the bug where the Javascript special passage is not executed?
  • Ok so... I manage to fix my troubles. I want to report here on how I did it, in case it could help someone else. Keep it mind that this is probably the dirtiest fix ever, because I know mostly nothing about javascript and coding for the web. And my fix probably won't work if the player is playing on a mobile device (I haven't tested).

    In Edit Story Javascript, copy this:
    document.onclick = function() {
    window.scrollTo(0, 0);
    }
    This code will make so that every click on the page will scroll the page back to the top, which means that when the player clicks on a link, the page will be at the top for when the next passage is displayed. I didn't know how to detect only clicks on links, so that's why it detects all clicks, even if the player clicks on nothing. Like I said, it's a dirty fix.

    Edit: Not required anymore :)
    Also, since the javascript in the special javascript passage is currently not executed in Harlowe because of a bug, you have to manually edit the exported HTML source file and add this code before the </body> tag (it's at the very bottom of the page):

    We have to thanks our friend greyelf for that one. His full message and instructions are here: http://twinery.org/forum/index.php/topic,2132.msg6198.html#msg6198


    So yeah... That's a bit complicated, but hopefully all of this will be fixed in the next Twine update and the next Harlowe update. In the meantime, I can now FINALLY release my story, so I'm very happy! :)
  • It should be fixed now that 2.0.1 is out... right?
  • The new version of the Harlowe story format that comes with Twine 2.0.1 processes the special Stylesheet and Javascript passages, so there should be no need to edit the generated HTML file to get your CSS or Javascript to work if you upgrade to 2.0.1.
  • Indeed, I don't have to cut and paste the javascript code into the source file, but I still need to put my code to scroll back to the top of the page. Otherwise, the page won't scroll back to the top when I click a link.
Sign In or Register to comment.