mysterymagination / adventures-of-mooty-wort

An Undum eval tale, short and sweet
MIT License
0 stars 0 forks source link

transcript needs to scroll to post combat locations #24

Closed mysterymagination closed 3 years ago

mysterymagination commented 3 years ago

I'm finding myself back up at the top of the transcript whenever I transition back from the combat UI -- behavior should be to scroll to the top of the latest text snoppet written

mysterymagination commented 3 years ago

hmm, curious...

  1. I'm seeing the restoreTranscriptYPos console log before I hit the exit image; my understanding of the promise stack was that the result string business at the end of the chain shouldn't have run until after handleCombatResult's await had settled, which shouldn't happen until we bop the exit image.
  2. If I shove the restoreTranscriptYPos call into the exit door image onload right after we restore the display prop of the transcript, we see the log as expected (after the transcript actually becomes visible again) but no scrolling actually occurs.
mysterymagination commented 3 years ago

problem re: 1 above was that I misunderstood the mechanism of keyword await -- it essentially just pauses execution until the promise in the expression following it is settled; it does not give any provisions for effectively controlling when that will happen, as .then() provides. Judging by example code, you have to manually have a new Promise with explicit resolve/reject functions within the behavior of the promise you're awaiting on and make sure the outer promise doesn't settle until the inner promise does, e.g. by having another await on the inner promise. Interestingly, you don't actually have to define the resolve/reject functions anyplace -- you can just name them whatever as args in the promise behavior lambda function and then call them as needed therein. I guess default ones that simply set the promise state to fulfilled/rejected and fate to resolved are provided implicitly when the promise is constructed if not given by a then call?

mysterymagination commented 3 years ago

as for point 2 above, I'm still not scrolling to the saved location BUT the Undum scrolling to the basement2_hub situation seems to be working now; I'd guess said situation transition is overriding our manual scroll and that any scrolling is now working because we repaired the await situation in handleCombatResult.

Now where the trype did my victory jingle get to?

mysterymagination commented 3 years ago

hm, I moved the jingle onload def up above the await result switch and it works fine now; not sure why it didn't run when I clicked the image when I had it installed after the await switch... mysterious, but stupid. Pretty sure the issue is that canplaythrough events on audio objects must not be 'sticky' -- if the event fires and there's no one around to hear it, it just gets dropped. Someone coming on by later is not notified that the object already is in a canplaythrough state.