S
S
SN7iNC2018-03-22 02:47:03
JavaScript
SN7iNC, 2018-03-22 02:47:03

Super scroll with mouse wheel on anchors?

Good day. This question has already been raised on the toaster and there is an answer and a solution to the problem, but there is also one drawback (big for me), which I beg you to help me solve.

Lakewake - here he suggested a very good (in my opinion) algorithm for solving this issue (at least I haven’t found a better solution for my needs yet) - Scroll works perfectly, the disadvantage is that the scroll stops at the last anchor and freezes in place , the page has not ended yet and there is some content, but since there are no more anchors, there is no way to continue scrolling up (down works).

With proper distribution of anchors, as a rule, this remains a small piece of ~ 100px, but the value is not constant.
If you do not set anchors at all, and there is still a lot of content after the last anchor, then it is not possible to see it.

Example: https://jsfiddle.net/wqL8btcw/

You can also anchor the very last div But! In this case, the content that will be between the penultimate and last div will be scrolled and not seen.

The essence of the question is to improve this script, namely to make it so that:

  • 1. While scrolling up and down - scrolling is carried out by anchors (Anh1, Anh2, Anh3, Anh4, .....n)
  • 2. After the last anchor - the possibility of a normal (standard, simple, browser) scroll has returned. (Anh1, Anh2, Anh3, Anh4, .....n, end of page)
  • 3. Having scrolled to the end of the page (by standard scrolling), while scrolling down, everything happened in the reverse order. (end of page, n..... Anh4, Anh3, Anh2, Anh1)


In the example (above), you can see that the scrolll freezes at paragraph 3, since the 3 div is the last anchor.

I honestly do not understand JS and jQuery, I ask for your help ....

Answer the question

In order to leave comments, you need to log in

1 answer(s)
O
Oleg, 2018-03-22
@politon

I didn’t even look at your code, but what prevents you from setting a condition for the last block botton: 0;
Although it is logical to tie the anchor to top

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question