1

I need to manipulate user scroll in next way:

Scroll example

When user in some <section> he can only scroll slowly, then if he will reach ~80% of the section, automatically scroll to the top of the next <section>

Detailed explanation: I need to slow down the scroll inside an element (in my case it's <section>) and if the view of the <section> is scrolled more than 80% scroll to the top of the next section.

The main question is how to slow down the scroll. How to scroll to the next section after 80% of the current is less important.

Farhad
  • 4,119
  • 8
  • 43
  • 66
Demyd Ganenko
  • 108
  • 1
  • 9

1 Answers1

1

you can use jquery to scroll up/down or scroll to an element.

you can say:

if ($(this).scrollTop() > 100)
{
    // do some thing 
}

I also calculate height percent like this:

var h = (($("#one").height())*80/100);

See jsfiddle: https://jsfiddle.net/q36fLcaa/

Farhad
  • 4,119
  • 8
  • 43
  • 66
  • Thank you for that, but how to slow down the scroll speed and make it smooth for browsers that immediately scrolls some amount of pixels (e.g. Chrome on Windows). – Demyd Ganenko May 29 '16 at 08:23
  • @Demid Ganenko I found: http://stackoverflow.com/questions/7408100/can-i-change-the-scroll-speed-using-css-or-jquery for slow down scroll speed and jsfiddle: http://jsfiddle.net/promatik/NFk2L/ see that's work for you. – Farhad May 29 '16 at 08:27
  • found it too. But after some search used it https://github.com/inuyaksa/jquery.nicescroll – Demyd Ganenko May 29 '16 at 09:56