diff --git a/src/control.class.js b/src/control.class.js index 4cbbf0fc036..be0a59f2e02 100644 --- a/src/control.class.js +++ b/src/control.class.js @@ -2,17 +2,9 @@ 'use strict'; - var fabric = global.fabric || (global.fabric = { }), - util = fabric.util, - renderCircleControl = fabric.controlRenderers.renderCircleControl, - renderSquareControl = fabric.controlRenderers.renderSquareControl; + var fabric = global.fabric || (global.fabric = { }); function Control(options) { - if (options.position) { - this.x = options.position.x; - this.y = options.position.y; - } - delete options.position; for (var i in options) { this[i] = options[i]; } @@ -198,7 +190,7 @@ positionHandler: function(dim, finalMatrix /*, fabricObject, currentControl */) { - var point = util.transformPoint({ + var point = fabric.util.transformPoint({ x: this.x * dim.x + this.offsetX, y: this.y * dim.y + this.offsetY }, finalMatrix); return point; @@ -221,10 +213,10 @@ styleOverride = styleOverride || {}; switch (styleOverride.cornerStyle || fabricObject.cornerStyle) { case 'circle': - renderCircleControl.call(this, ctx, left, top, styleOverride, fabricObject); + fabric.controlRenderers.renderCircleControl.call(this, ctx, left, top, styleOverride, fabricObject); break; default: - renderSquareControl.call(this, ctx, left, top, styleOverride, fabricObject); + fabric.controlRenderers.renderSquareControl.call(this, ctx, left, top, styleOverride, fabricObject); } }, }; diff --git a/src/mixins/default_controls.js b/src/mixins/default_controls.js index 7351612eefa..a7a6656eee0 100644 --- a/src/mixins/default_controls.js +++ b/src/mixins/default_controls.js @@ -11,7 +11,8 @@ objectControls.ml = new fabric.Control({ name: 'ml', - position: { x: -0.5, y: 0 }, + x: -0.5, + y: 0, cursorStyleHandler: scaleSkewStyleHandler, actionHandler: scalingXOrSkewingY, getActionName: scaleOrSkewActionName, @@ -19,7 +20,8 @@ objectControls.mr = new fabric.Control({ name: 'mr', - position: { x: 0.5, y: 0 }, + x: 0.5, + y: 0, cursorStyleHandler: scaleSkewStyleHandler, actionHandler: scalingXOrSkewingY, getActionName: scaleOrSkewActionName, @@ -27,7 +29,8 @@ objectControls.mb = new fabric.Control({ name: 'mb', - position: { x: 0, y: 0.5 }, + x: 0, + y: 0.5, cursorStyleHandler: scaleSkewStyleHandler, actionHandler: scalingYOrSkewingX, getActionName: scaleOrSkewActionName, @@ -35,7 +38,8 @@ objectControls.mt = new fabric.Control({ name: 'mt', - position: { x: 0, y: -0.5 }, + x: 0, + y: -0.5, cursorStyleHandler: scaleSkewStyleHandler, actionHandler: scalingYOrSkewingX, getActionName: scaleOrSkewActionName, @@ -43,35 +47,40 @@ objectControls.tl = new fabric.Control({ name: 'tl', - position: { x: -0.5, y: -0.5 }, + x: -0.5, + y: -0.5, cursorStyleHandler: scaleStyleHandler, actionHandler: scalingEqually }); objectControls.tr = new fabric.Control({ name: 'tr', - position: { x: 0.5, y: -0.5 }, + x: 0.5, + y: -0.5, cursorStyleHandler: scaleStyleHandler, actionHandler: scalingEqually }); objectControls.bl = new fabric.Control({ name: 'bl', - position: { x: -0.5, y: 0.5 }, + x: -0.5, + y: 0.5, cursorStyleHandler: scaleStyleHandler, actionHandler: scalingEqually }); objectControls.br = new fabric.Control({ name: 'br', - position: { x: 0.5, y: 0.5 }, + x: 0.5, + y: 0.5, cursorStyleHandler: scaleStyleHandler, actionHandler: scalingEqually }); objectControls.mtr = new fabric.Control({ name: 'mtr', - position: { x: 0, y: -0.5 }, + x: 0, + y: -0.5, actionHandler: controlHandlers.rotationWithSnapping, cursorStyleHandler: controlHandlers.rotationStyleHandler, offsetY: -40, @@ -97,7 +106,8 @@ textBoxControls.mr = new fabric.Control({ name: 'mr', - position: { x: 0.5, y: 0 }, + x: 0.5, + y: 0, actionHandler: controlHandlers.changeWidth, cursorStyleHandler: scaleSkewStyleHandler, actionName: 'resizing', @@ -105,7 +115,8 @@ textBoxControls.ml = new fabric.Control({ name: 'ml', - position: { x: -0.5, y: 0 }, + x: -0.5, + y: 0, actionHandler: controlHandlers.changeWidth, cursorStyleHandler: scaleSkewStyleHandler, actionName: 'resizing',