Skip to content

Commit

Permalink
Fixed issue with too sensitive scroll wheels #62
Browse files Browse the repository at this point in the history
  • Loading branch information
Yqnn committed Mar 5, 2022
1 parent 3bdf1ac commit 02136b0
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/app/canvas/canvas.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -111,12 +111,13 @@ export class CanvasComponent implements OnInit, OnChanges, AfterViewInit {
}

ngOnInit(): void {
const cap = (val:number, max:number) => val > max ? max : val < -max ? -max : val;
const throttler = throttleTime(20, undefined, {leading: false, trailing: true});
this.wheel$
.pipe( buffer(this.wheel$.pipe(throttler)) )
.pipe( map(ev => ({
event: ev[0],
deltaY: ev.reduce((acc, cur) => acc + cur.deltaY, 0)
deltaY: ev.reduce((acc, cur) => acc + cap(cur.deltaY, 50), 0)
})))
.subscribe(this.mousewheel.bind(this));
}
Expand Down

0 comments on commit 02136b0

Please sign in to comment.