ScrolltoEnd fix Reversal
RedBenny
15 Apr 2020, 06:39tl;dr:
How do I turn scrolltoend back on after having turned it off with this:
JS.eval ("scrollToEnd = function () {}")
ts;dc:
Hi. I, like many posting here (specifically on the topic of the annoying "scrolltoend" function Quest weirdly makes default {and frustratingly neglects to add an option to disable}) am new to this.
I have been working on a GameBook style because the TextAdventure style looks too scary, complicated, and overall to spoopy for me. I have the 'clearscreen' function active in Quests native options, but as I absolutely do not want to watch every page try to leave me as soon as I say hello, I wanted to find a way to disable the function.
So I went digging through elgoog and found this wonderful little copy/paste script from Pykrete:
JS.eval ("scrollToEnd = function () {}")
This does exactly what I want it to. However, I do not know how to reverse it ingame once it has been enacted.
Essentially, I want to create an option ingame so that players can choose whether or not Auto-Scroll is enabled, operating by way of switch. I want this because Auto-Scroll makes testing game path options a breeze, and because not everyone wants to read everything, and because I want to include an element of replayability with multiple ends (meaning experienced players won't wish to remove their devastated dexterous digits {likely with an axe} for want of an Auto-Scroll feature that I have disabled from game start [while still allowing players to save and reload a game and not be stuck scrolling themselves if they don't want to}) .
There are undoubtedly many ways of accomplishing this that are very clever indeed, but considering my only experience in coding comes from the WarCraft 3 WorldEditor and two years of playing minesweeper in highschool software, I only want something simple that turns the function on from being off, and allows it to then be switched off if they so choose.
I've already got an option that switches from night mode to day mode, so I can implement the switch operation. I just can't reverse that lovely line of code.
If you can help, cool. If not, all g, I'm sure I'll live. Unless this:
)"}{ )( noiɈɔnυʇ = bnƎoTlloɿɔƨ"( lɒvɘ.ƧႱ
Somehow summons a Hellish creature from deep within Quest when it is evoked.
Thanks in advance,
Red
P.S. Thanks to Pykrete for the lovely line.
mrangel
15 Apr 2020, 09:36JS.eval("scrollToEnd = function () { $('html,body').animate({ scrollTop: document.body.scrollHeight }); };")
RedBenny
15 Apr 2020, 23:27Perfect, works as needed. Much appreciated, mrangel.
For those in need, this prevents auto-scroll / scrolltoend :
JS.eval ("scrollToEnd = function () {}")
This reinstates it after it has been disabblled by the first:
JS.eval("scrollToEnd = function () { $('html,body').animate({ scrollTop: document.body.scrollHeight }); };")
Again, thanks to both Pykrete and mrangel for their respective lines of code. I hope this can help others out there starting out and struggling with these simple problems, as it did me.
mrangel
16 Apr 2020, 00:18If you're turning it on and off often, you could create a frame to hold the function. More efficient than compiling it every time. The script would look like this:
JS.eval("$(function () {var a=ScrollToEnd;var b=x=>x;EnableAutoscroll=function() {ScrollToEnd=a};DisableAutoscroll=function() {ScrollToEnd=b;};});")
If you put that in your UI Initialisation script, then you can just do:
JS.EnableAutoscroll()
or
JS.DisableAutoscroll()
each time you need them.
It's probably worth pointing out that – as with all the JS.
functions in Quest – these changes will not be saved with a saved game. So if you disable automatic scrolling and the player saves the game, it will be saving again when they reload unless the UI Initialisation script disables it. If you're turning ScrollToEnd off and on again, you should have a script in the UI Initialisation that checks what its current state should be, and turns it off if necessary.
Deckrect
16 Apr 2020, 13:29Great! It has been a big issue for me sinve long time! Thank you guys!