# HG changeset patch # User Alexandre Segura # Date 1487684119 -3600 # Node ID 74cdfdfa9f22eaccd64e3343eeb8f455230e2d60 # Parent 64a8800e63ebdc4d1a022a6f890205d5c53e137c Remove duplicate code. diff -r 64a8800e63eb -r 74cdfdfa9f22 src_js/iconolab-bundle/src/components/editor/Canvas.vue --- a/src_js/iconolab-bundle/src/components/editor/Canvas.vue Mon Feb 20 23:56:15 2017 +0100 +++ b/src_js/iconolab-bundle/src/components/editor/Canvas.vue Tue Feb 21 14:35:19 2017 +0100 @@ -365,20 +365,11 @@ var currentPosition = { x: 0, y: 0 }; var canDraw = false; - var computeOffset = (e) => { - var rect = this.$refs.image.getBoundingClientRect(); - var zoomOffset = this.zoomOffset(); - var offsetX = (e.clientX - rect.left) / Math.min(zoomOffset.x, zoomOffset.y); - var offsetY = (e.clientY - rect.top) / Math.min(zoomOffset.x, zoomOffset.y); - - return { x: offsetX, y: offsetY }; - } - this.paper.mousedown((e) => { if (this.$refs.rect.width > 0 && this.$refs.rect.height > 0) { return; } - startPosition = computeOffset(e); + startPosition = this.computeOffset(e); canDraw = true; }); @@ -387,7 +378,7 @@ if (!canDraw) { return; } var x, y; - currentPosition = computeOffset(e); + currentPosition = this.computeOffset(e); /* bas -> droite */ var width = Math.abs(currentPosition.x - startPosition.x); @@ -433,7 +424,7 @@ canDraw = false; if (this.$refs.rect.width === 0 && this.$refs.rect.height === 0) { - var currentPosition = computeOffset(e); + var currentPosition = this.computeOffset(e); Object.assign(this.$refs.rect, { x: currentPosition.x, y: currentPosition.y,