qmd-lab / closeread

https://closeread.dev
MIT License
128 stars 5 forks source link

Fix Scrollama problems on browser resize/zoom #107

Closed jimjam-slam closed 4 weeks ago

jimjam-slam commented 1 month ago

Fixes #101. Based on https://github.com/russellsamora/scrollama/issues/145#issuecomment-1764582014

jimjam-slam commented 1 month ago

Note that I thought I would need to manually reattach the Scrollama event handlers, so I moved them into named functions. I ended up just needing to call .resize() methods on the scroller objects, so the refactor into named functions ended up not being necessary. I think it improves readability and is worth keeping, but I can undo that part if you disagree!

andrewpbray commented 4 weeks ago

Testing it locally on chrome, the freeze-on-resize issue was still there (as was some jumpiness).

https://github.com/user-attachments/assets/cef46957-2c08-4394-8f95-07ff20f2f49c

I wanted to test it on the preview site, so I reran that job and, presto, no jumpiness and the resize/reload issue is fixed! Good to know that serving that stuff locally won't behave in quite the same manner.

Alright, I'll proceed with the review!

andrewpbray commented 4 weeks ago

Small note: in bcfcc66 I moved the second hotkey event listener inside the on-document-load after looking into it a bit a deciding that that probably makes the most sense for all of our listeners.