Skip to content

Commit

Permalink
Merge pull request #510 from paulkaplan/fix-bit-brush-touch
Browse files Browse the repository at this point in the history
Fix bit brush on touch devices
  • Loading branch information
paulkaplan authored Jun 13, 2018
2 parents 389eba6 + f785ac0 commit 38f2371
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 2 deletions.
1 change: 1 addition & 0 deletions src/components/forms/slider.css
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,5 @@
background-color: white;
border-radius: 100%;
box-shadow: 0 0 0 4px rgba(0, 0, 0, 0.15);
touch-action: none;
}
3 changes: 3 additions & 0 deletions src/helper/bit-tools/brush-tool.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,9 @@ class BrushTool extends paper.Tool {
}
// Draw a brush mark at the given point
draw (x, y) {
if (!this.tmpCanvas) {
this.tmpCanvas = getBrushMark(this.size, this.color);
}
const roundedUpRadius = Math.ceil(this.size / 2);
getRaster().drawImage(this.tmpCanvas, new paper.Point(~~x - roundedUpRadius, ~~y - roundedUpRadius));
}
Expand Down
7 changes: 5 additions & 2 deletions src/helper/bit-tools/line-tool.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,9 @@ class LineTool extends paper.Tool {
}
// Draw a brush mark at the given point
draw (x, y) {
if (!this.tmpCanvas) {
this.tmpCanvas = getBrushMark(this.size, this.color);
}
const roundedUpRadius = Math.ceil(this.size / 2);
this.drawTarget.drawImage(this.tmpCanvas, new paper.Point(~~x - roundedUpRadius, ~~y - roundedUpRadius));
}
Expand Down Expand Up @@ -72,8 +75,8 @@ class LineTool extends paper.Tool {
handleMouseDown (event) {
if (event.event.button > 0) return; // only first mouse button
this.active = true;
this.cursorPreview.remove();

if (this.cursorPreview) this.cursorPreview.remove();

const tmpCanvas = document.createElement('canvas');
tmpCanvas.width = ART_BOARD_WIDTH;
Expand Down

0 comments on commit 38f2371

Please sign in to comment.