From 9e64d3cade47fe0efbe1683d06e0886f5c81d49f Mon Sep 17 00:00:00 2001 From: pkova Date: Wed, 16 Sep 2020 19:25:45 +0300 Subject: [PATCH] webchat: fix slow scrolling --- pkg/interface/package.json | 3 ++- pkg/interface/src/views/components/VirtualScroller.tsx | 6 ++++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/pkg/interface/package.json b/pkg/interface/package.json index 45e644e8b4..19e5448dfe 100644 --- a/pkg/interface/package.json +++ b/pkg/interface/package.json @@ -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", diff --git a/pkg/interface/src/views/components/VirtualScroller.tsx b/pkg/interface/src/views/components/VirtualScroller.tsx index c5b98816ca..cbbd15090d 100644 --- a/pkg/interface/src/views/components/VirtualScroller.tsx +++ b/pkg/interface/src/views/components/VirtualScroller.tsx @@ -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 { 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 }); @@ -306,4 +308,4 @@ export default class VirtualScroller extends PureComponent ); } -} \ No newline at end of file +}