Remove duplicate code.
--- 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,