-Webkit-scroll bar + overflow + jQuery scrollTop always returns zero

I have been working on this error all day and cannot solve it.

You have a jQuery scrollTop script scroll animation that detects the value of $ (window) .scrollTop () and does some animation and if you click the scroll button up. $ (this) .click (function () {$ ("html, body"). animate ({scrollTop: 0}, "fast");});

This works fine. and I always get scrollTop value ... To →

When using a custom scrollbar for the browser, you must installed in css

html → overflow: hidden Body → position: absolute, overflow-y: scroll, overflow-x: auto

The html hierarchy is just normal html-> body-> div container → div content, etc.

Now that the browser scroll bar has been removed and you have your own custom scroll bar, the scrollTop value always returns zero.

Tried everything I can think of, no matter what other code I tried, the scrollTop value always returns zero.

So, nothing revives, and nothing scrolls back.

Does anyone know how to get the value when using custom * web browser -webkit-scrollbar to scroll up? *

+4
source share
3 answers

You no longer scroll the window, you scroll the inner element, so you should try:

$(html).scrollTop() $(body).scrollTop() 

and see if 0 changes

+1
source

What happens when you remove overflow: hidden and position: absolute from html and body CSS?

0
source

I believe this is a bug that has not yet been fixed. Check here https://bugs.webkit.org/show_bug.cgi?id=9248

and check out the last comment that shows this demo ( http://maisqi.com/outros/bugs/chrome/CHN6 ), which still doesn't work in webkit-based browsers.

0
source

Source: https://habr.com/ru/post/1337198/


All Articles