From 704b06ed44028b82062c74d6a673d1a45ff4c416 Mon Sep 17 00:00:00 2001 From: Daniel Imms <2193314+Tyriar@users.noreply.github.com> Date: Wed, 17 Mar 2021 12:48:56 -0700 Subject: [PATCH] Support ballistic scroll Fixes #227 --- media/editor/scrollBarHandler.ts | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/media/editor/scrollBarHandler.ts b/media/editor/scrollBarHandler.ts index c8e6a7b..6600020 100644 --- a/media/editor/scrollBarHandler.ts +++ b/media/editor/scrollBarHandler.ts @@ -101,10 +101,17 @@ export class ScrollBarHandler { // if these are equal it means the document is too short to scroll anyways if (this.scrollBarHeight === this.scrollThumbHeight) return; if (event.deltaY === 0 || event.shiftKey) return; - if (event.deltaY > 0) { - this.updateVirtualScrollTop(this.scrollTop + this.rowHeight); - } else { - this.updateVirtualScrollTop(this.scrollTop - this.rowHeight); + switch (event.deltaMode) { + case WheelEvent.DOM_DELTA_LINE: + if (event.deltaY > 0) { + this.updateVirtualScrollTop(this.scrollTop + this.rowHeight); + } else { + this.updateVirtualScrollTop(this.scrollTop - this.rowHeight); + } + break; + case WheelEvent.DOM_DELTA_PIXEL: + default: // Fallback to pixel + this.updateVirtualScrollTop(this.scrollTop + event.deltaY); } this.updateScrolledPosition();