From 3d83837754ac27575a81bc8aaed99ca59b770e9f Mon Sep 17 00:00:00 2001 From: wwayne Date: Sat, 16 Jan 2021 08:42:18 +0800 Subject: [PATCH] fix: touchpad horizontal scrolling --- src/index.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/index.js b/src/index.js index 8fc7d89..ac4b2d8 100644 --- a/src/index.js +++ b/src/index.js @@ -121,8 +121,9 @@ export default class HorizontalScroll extends Component { onWheel (e) { const currentTrack = document.getElementById(this.trackId) if (currentTrack) { + const delta = Math.abs(e.deltaX) > Math.abs(e.deltaY) ? e.deltaX : e.deltaY const currentTrackLeft = currentTrack.style.left || '0px' - this.updateTrackLeft(parseFloat(currentTrackLeft.replace('px', '')) + e.deltaY) + this.updateTrackLeft(parseFloat(currentTrackLeft.replace('px', '')) + delta * 0.45) } }