mirror of https://github.com/Siphonay/mastodon
Fixed a bug where the canvas would get transparent bg upon erase
This commit is contained in:
parent
33e806217f
commit
2af964ef20
|
@ -17,10 +17,15 @@ export default class DoodleModal extends ImmutablePureComponent {
|
||||||
|
|
||||||
handleKeyUp = (e) => {
|
handleKeyUp = (e) => {
|
||||||
if (e.key === 'Delete' || e.key === 'Backspace') {
|
if (e.key === 'Delete' || e.key === 'Backspace') {
|
||||||
this.sketcher.clear();
|
this.clearScreen();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
clearScreen () {
|
||||||
|
this.sketcher.context.fillStyle = 'white';
|
||||||
|
this.sketcher.context.fillRect(0, 0, this.canvas.width, this.canvas.height);
|
||||||
|
}
|
||||||
|
|
||||||
componentDidMount () {
|
componentDidMount () {
|
||||||
window.addEventListener('keyup', this.handleKeyUp, false);
|
window.addEventListener('keyup', this.handleKeyUp, false);
|
||||||
}
|
}
|
||||||
|
@ -36,9 +41,7 @@ export default class DoodleModal extends ImmutablePureComponent {
|
||||||
if (elem) {
|
if (elem) {
|
||||||
this.sketcher = new Atrament(elem, 500, 500, 'black');
|
this.sketcher = new Atrament(elem, 500, 500, 'black');
|
||||||
|
|
||||||
// pre-fill with white
|
this.clearScreen();
|
||||||
this.sketcher.context.fillStyle = 'white';
|
|
||||||
this.sketcher.context.fillRect(0, 0, elem.width, elem.height);
|
|
||||||
|
|
||||||
// .smoothing looks good with mouse but works really poorly with a tablet
|
// .smoothing looks good with mouse but works really poorly with a tablet
|
||||||
this.sketcher.smoothing = false;
|
this.sketcher.smoothing = false;
|
||||||
|
|
Loading…
Reference in New Issue