From 9ccb4a7bc728fd0e85c04fddb802fde02b73cfe2 Mon Sep 17 00:00:00 2001 From: sanine Date: Sun, 29 May 2022 20:44:11 -0500 Subject: add basic color brushing demo --- src/Canvas.js | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'src/Canvas.js') diff --git a/src/Canvas.js b/src/Canvas.js index 7f6404b..6dff7bd 100644 --- a/src/Canvas.js +++ b/src/Canvas.js @@ -22,6 +22,8 @@ class Canvas { /* callbacks */ this.onDraw = null; this.onMouseMove = null; + this.onMouseDown = null; + this.onMouseUp = null; /* register event listeners */ @@ -53,9 +55,11 @@ class Canvas { this.element.addEventListener('mousedown', e => { e.preventDefault(); if (e.button === 1) this.panning = true; + if (this.onMouseDown) this.onMouseDown(e); }); this.element.addEventListener('mouseup', e => { if (e.button === 1) this.panning = false; + if (this.onMouseUp) this.onMouseUp(e); }); /* mouse leave */ -- cgit v1.2.1