【问题标题】:How to disable smooth scrolling in Chrome如何在 Chrome 中禁用平滑滚动
【发布时间】:2012-09-26 16:45:12
【问题描述】:

我正在创建一个网络应用程序(主要集中在 Chrome 中的使用),但是 Chrome 的“平滑滚动”(我猜这就是所谓的,像 IOS 上的“额外”滚动)(在 Mac 上时)碍事。

有没有办法通过javascript禁用它?

【问题讨论】:

    标签: javascript google-chrome scroll


    【解决方案1】:

    通过拦截滚轮事件并“手动”移动 scrollTop/scrollLeft 像素位置,我能够缓解平滑滚动时遇到的一些渲染问题:

    function wheeled(event) {
      event.preventDefault()
    
      container.scrollTop += event.deltaY
      container.scrollLeft += event.deltaX
    }
    
    container.addEventListener('wheel', wheeled, { passive: false, capture: true })
    // actual render code is in the `scrolled` handler because
    // there are other wheel events in the code that adjust the scroll position
    container.addEventListener('scroll', scrolled, { passive: true })
    

    【讨论】:

    • 谢谢。这正是我所需要的——真的让我摸不着头脑。
    【解决方案2】:

    使用 Javascript 设置 HTML 和 BODY 标签的 CSS 样式。

    将它们的“溢出”属性设置为“隐藏”。

    【讨论】:

      【解决方案3】:

      您所说的平滑滚动称为过度滚动反弹或橡皮筋滚动。

      Disable iOS Overscroll but allow body scrolling

      【讨论】:

        猜你喜欢
        • 2015-06-07
        • 2017-10-01
        • 1970-01-01
        • 1970-01-01
        • 2017-07-25
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多