trevorcampbell / website_diff

MIT License
2 stars 1 forks source link

Add a wait for page to be finished loading before auto-scroll to first diff #14

Closed trevorcampbell closed 3 weeks ago

trevorcampbell commented 1 month ago

See the new example here:

https://python.datasciencebook.ca/diff350/index.html

When I first go to a "diff'd" page, it tries to autoscroll to the first diff. But the page hasn't finished loading yet, so it gets stuck somewhere in the middle.

If I revisit the page again later, it works fine (because my browser has cached the whole page)

@briank-git I suspect we need to add an explicit wait until the page is done loading before the autoscroll happens.

(fun fact: I didn't change anything in the book except for the version control chapter. So all the diffs that are highlighted in classification1,2 etc are unintended changes that were caught! :D )

trevorcampbell commented 1 month ago

I think here https://github.com/trevorcampbell/website_diff/blob/fe6710ae6c0cd079bbbf444c8c4bb7754b6b7afb/website_diff/static/website_diff.js#L3

we need to replace

$(document).ready(function() { ... })

with

$( window ).on( "load", function() { ... })

to make sure the page is fully loaded