Skip to content

Commit

Permalink
Support ballistic scroll
Browse files Browse the repository at this point in the history
Fixes #227
  • Loading branch information
Tyriar committed Mar 17, 2021
1 parent 03ebf9a commit 704b06e
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions media/editor/scrollBarHandler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down

0 comments on commit 704b06e

Please sign in to comment.