如何在Chrome中禁用平滑滚动 [英] How to disable smooth scrolling in Chrome

查看:1114
本文介绍了如何在Chrome中禁用平滑滚动的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在创建一个网络应用程序(主要关注Chrome中的使用情况),但Chrome的平滑滚动(我想这就是所谓的多余滚动,就像IOS一样)(在Mac上)挡道。

有没有什么办法可以通过javascript禁用这个功能?

我可以通过拦截轮子事件并移动 scrollTop / scrollLeft 来缓解一些渲染问题,像素位置手动:

 函数wheeled(event){
event.preventDefault()

container.scrollTop + = event.deltaY
container.scrollLeft + = event.deltaX
}

container.addEventListener('wheel',wheeled,{passive: false,capture:true})
//实际渲染代码在`scrolled`处理函数中,因为
//代码中有其他轮子事件调整滚动位置
container.addEventListener ('scroll',scrolled,{passive:true})


I'm creating a web app (that's mostly focused on usage in Chrome), but the 'smooth scrolling' (I guess that's what it's called, the 'extra' scrolling like on IOS) of Chrome (when on mac) gets in the way.

Is there any way to disable this via javascript?

解决方案

I was able to mitigate some rendering issues I was having with smooth scrolling by intercepting wheel events and moving the scrollTop/scrollLeft pixel positions "by hand":

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 })

这篇关于如何在Chrome中禁用平滑滚动的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆