-2

I developed a webpage which loads and positions itself at a certain vertical scroll position for the user (depending on various factors unique to their account). It is not suitable to use a url anchor/hash in this case

Instead I use jQuery to scroll to the desired position, in the $(document).ready

This all works fine, except the page also tends to contain hotlinked images

Once these images have loaded, it suddenly results in the page becoming longer (and the position I automatically scrolled to is no longer accurate).. In Chrome at least, it doesn't compensate and just leaves the user staring at the same vertical pixel scroll position.

So I now plan to improve this by doing a 2nd scrollTo in $(window).load(), after all images have been loaded.... but only if the user has not already scrolled from the original position I set in document.ready()

What would be the best way to detect this?

carpii
  • 1,917
  • 4
  • 20
  • 24
  • where is your code???? – Amit Kumar Pawar Sep 08 '16 at 04:28
  • Would it not be better if you specify height of the hotlinked images so that the entire problem doesn't originate? – Awol Sep 08 '16 at 06:19
  • @Awol, I cannot really do that. The dimensions of hotlinked images are not known until they have already loaded. I could limit them to a max height but they may be much smaller, so I would still have the same issue – carpii Sep 09 '16 at 12:32

1 Answers1

1

You can use the .scroll method to detect when a user scrolls a page.

DEMO

Reference this question/answer for a more detailed function/code.

Community
  • 1
  • 1
justinw
  • 3,856
  • 5
  • 26
  • 41