0

I'd like to create a function that block the scroll for a couple of seconds when I'm at certain points of the page or when a div become visible.

I'm using the .waypoint plugin to trigger the function, I've tried the css "overflow: hidden" method but doesn't work well: it isn't immediate (if I scroll fast it activates late) and It creates some issues with the layout because of the disappearing of the scrollbar.

Any suggestion?

Francesco Bianchi
  • 772
  • 1
  • 4
  • 13
  • Perhaps this might be a good starting point: http://stackoverflow.com/questions/4770025/how-to-disable-scrolling-temporarily . I would personally move in this way: If you have an event such as a div that is going to hide, once the hide event is triggered force the document to **focus** that div, then block the scroll. Else, just check if the scroll coords matches the desired position and block the scrolling using a similar way (or the same way) shown in the link above. Hope this helps :) – briosheje Feb 19 '15 at 11:28
  • It works pretty good thanks! It just bother me that if I scroll fast It doesn't block the page exactly where i wanted – Francesco Bianchi Feb 19 '15 at 11:45
  • For such thing you may want to actually manually focus the div. If you can do such by following something like this: http://stackoverflow.com/questions/635706/how-to-scroll-to-an-element-inside-a-div . Once the div hiding is triggered, force the dom to scroll to the position desired. In any case, regardless how fast you are scrolling, the script will be executed and will bring you to where you want to go. The idea, to me, is: 1) triggering the div hide. 2) Disable scroll. 3) Bring the view to the hidden div position or wherever you want it to go. In this way you should be 100% sure. – briosheje Feb 19 '15 at 13:49

0 Answers0