Disable momentum scrolling on Chrome for Android

天涯浪子 提交于 2020-01-22 12:49:25

问题


I'm looking for a way to disable the momentum scrolling on Chrome for Android device. I have a div with a fixed height and I want to be able to scroll the content of that div but without the smooth effect.

On iOS it's easy, I just havn't add the "-webkit-overflow-scrolling: touch", but it looks like Chrome for Android apply this automatically.

When I inspect the code with Chrome -> Device inspection I don't see this property so I think that Chrome do that nativly and I havn't found a way to prevent that.

I tried preventDefault on touchend but it doesn't work.

Any suggestion ?

Thanks. :)


回答1:


This is a quote from code.google.com from the chromium project

"We removed -webkit-overflow-scrolling with the hopes that it was no longer necessary because we'd automatically opt-in to fast scrolling when we need."

-webkit-overflow-scrolling: touch;

That rule got removed somwhere between Jan and Feb in 2013
The only way to get around the problem now on Chrome something to do it like this

<div style="overflow: auto">
    <div style="z-index: 0">
        Content
    </div>
</div>

The fix would be to set zindex: 0 on only "overflow: scroll" elements.



来源:https://stackoverflow.com/questions/25507566/disable-momentum-scrolling-on-chrome-for-android

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!