Skip to content

Commit

Permalink
Allow to change the brush-size with the mouse-wheel (#271)
Browse files Browse the repository at this point in the history
  • Loading branch information
simonbethke authored Nov 8, 2024
1 parent 6886d52 commit d33c4de
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions src/tools/brush-selection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -104,12 +104,22 @@ class BrushSelection {
}
};

const wheel = (e: WheelEvent) => {
const delta = e.deltaX + e.deltaY;
if (e.shiftKey && delta !== 0) {
events.fire(delta > 0 ? 'tool.brushSelection.smaller' : 'tool.brushSelection.bigger');
e.preventDefault();
e.stopPropagation();
}
};

this.activate = () => {
svg.style.display = 'inline';
parent.style.display = 'block';
parent.addEventListener('pointerdown', pointerdown);
parent.addEventListener('pointermove', pointermove);
parent.addEventListener('pointerup', pointerup);
parent.addEventListener('wheel', wheel);
};

this.deactivate = () => {
Expand All @@ -122,6 +132,7 @@ class BrushSelection {
parent.removeEventListener('pointerdown', pointerdown);
parent.removeEventListener('pointermove', pointermove);
parent.removeEventListener('pointerup', pointerup);
parent.removeEventListener('wheel', wheel);
};

events.on('tool.brushSelection.smaller', () => {
Expand Down

0 comments on commit d33c4de

Please sign in to comment.