Skip to content

Commit

Permalink
Work around Chrome 102 wheel scrolling bug
Browse files Browse the repository at this point in the history
  • Loading branch information
marijnh committed May 30, 2022
1 parent 17897ea commit 1c58686
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
13 changes: 12 additions & 1 deletion src/display/scroll_events.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { chrome, gecko, ie, mac, presto, safari, webkit } from "../util/browser.js"
import { chrome, chrome_version, gecko, ie, mac, presto, safari, webkit } from "../util/browser.js"
import { e_preventDefault } from "../util/event.js"

import { updateDisplaySimple } from "./update_display.js"
Expand Down Expand Up @@ -40,6 +40,17 @@ export function wheelEventPixels(e) {
}

export function onScrollWheel(cm, e) {
// On Chrome 102, viewport updates somehow stop wheel-based
// scrolling. Turning off pointer events during the scroll seems
// to avoid the issue.
if (chrome && chrome_version >= 102) {
if (cm.display.chromeScrollHack == null) cm.display.sizer.style.pointerEvents = "none"
else clearTimeout(cm.display.chromeScrollHack)
cm.display.chromeScrollHack = setTimeout(() => {
cm.display.chromeScrollHack = null
cm.display.sizer.style.pointerEvents = ""
}, 100)
}
let delta = wheelEventDelta(e), dx = delta.x, dy = delta.y
let pixelsPerUnit = wheelPixelsPerUnit
if (e.deltaMode === 0) {
Expand Down
3 changes: 2 additions & 1 deletion src/util/browser.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ export let ie = ie_upto10 || ie_11up || edge
export let ie_version = ie && (ie_upto10 ? document.documentMode || 6 : +(edge || ie_11up)[1])
export let webkit = !edge && /WebKit\//.test(userAgent)
let qtwebkit = webkit && /Qt\/\d+\.\d+/.test(userAgent)
export let chrome = !edge && /Chrome\//.test(userAgent)
export let chrome = !edge && /Chrome\/(\d+)/.exec(userAgent)
export let chrome_version = chrome && +chrome[1]
export let presto = /Opera\//.test(userAgent)
export let safari = /Apple Computer/.test(navigator.vendor)
export let mac_geMountainLion = /Mac OS X 1\d\D([8-9]|\d\d)\D/.test(userAgent)
Expand Down

2 comments on commit 1c58686

@krystian3w
Copy link

@krystian3w krystian3w commented on 1c58686 Jun 24, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Based on dimisa and gwarser relation no longer needed in 103 so for V8 engine fans in 102 release of Chromium possible change to simply equal (==) if strict equal (===) no work better than == or no match as identical these 102 numbers.

@marijnh
Copy link
Member Author

@marijnh marijnh commented on 1c58686 Jun 27, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See 571171d

Please sign in to comment.