Merge pull request #3494 from pkova/master

webchat: fix slow scrolling
This commit is contained in:
matildepark 2020-09-16 12:56:11 -04:00 committed by GitHub
commit dc3036af4c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 3 deletions

View File

@ -40,7 +40,8 @@
"suncalc": "^1.8.0",
"urbit-ob": "^5.0.0",
"urbit-sigil-js": "^1.3.2",
"yup": "^0.29.3"
"yup": "^0.29.3",
"normalize-wheel": "1.0.1"
},
"devDependencies": {
"@babel/core": "^7.9.0",

View File

@ -1,5 +1,6 @@
import React, { PureComponent } from 'react';
import _ from 'lodash';
import normalizeWheel from 'normalize-wheel';
interface VirtualScrollerProps {
origin: 'top' | 'bottom';
@ -220,7 +221,8 @@ export default class VirtualScroller extends PureComponent<VirtualScrollerProps,
if (this.props.origin === 'bottom') {
element.addEventListener('wheel', (event) => {
event.preventDefault();
element.scrollBy(0, event.deltaY * -1);
const normalized = normalizeWheel(event);
element.scrollBy(0, normalized.pixelY * -1);
return false;
}, { passive: false });
window.addEventListener('keydown', this.invertedKeyHandler, { passive: false });