diff --git a/js/core.js b/js/core.js index 5f2cced..92d8dd9 100644 --- a/js/core.js +++ b/js/core.js @@ -33,6 +33,14 @@ function Canvas(width, height, upscale) { that.pageY = e.touches[0].pageY; } + function unclicker(e) { + that.clicked = false; + + that.firstX = this.pageX; + that.firstY = this.pageY; + } + + this.elem.addEventListener('mousedown', function (e) { that.clicked = true; }); @@ -57,19 +65,9 @@ function Canvas(width, height, upscale) { e.preventDefault(); }) - this.elem.addEventListener('mouseup', function (e) { - that.clicked = false; + this.elem.addEventListener('mouseup', unclicker); - that.firstX = this.pageX; - that.firstY = this.pageY; - }); - - this.elem.addEventListener('touchend', function (e) { - that.clicked = false; - - that.firstX = this.pageX; - that.firstY = this.pageY; - }); + this.elem.addEventListener('touchend',unclicker); this.clicked = false;