move the source files to ./src

This commit is contained in:
Martin
2017-08-04 22:28:54 +02:00
parent 58dd1c66fd
commit f36d6f5915
37 changed files with 5 additions and 5 deletions
+49
View File
@@ -0,0 +1,49 @@
'use strict';
var util = require('./util');
/**
* @param {fabric.Image} img
* @param {fabric.Rect} boundingRect
*/
function Draggable(img, boundingRect) {
var _bounds = boundingRect;
/**
* Triggers when object is moved
*/
function onMove() {
this.__dragged = true;
this.canvas.disableScroll();
util.setPositionInside(this, _bounds);
}
// Attach onMove event to image
img.on('moving', onMove);
/**
* @param {fabric.Rect} localBoundingRect
* @return {Draggable}
*/
this.enable = function (localBoundingRect) {
if (localBoundingRect) {
_bounds = localBoundingRect;
}
// @TODO Refactor this, see Viewport.calcMinMaxBoundsForRect
if (img.canvas.getViewport().getData().axis === 'x') {
_bounds.top.min = _bounds.top.max = img.top;
} else {
_bounds.left.min = _bounds.left.max = img.left;
}
img.lockMovementX = img.lockMovementY = false;
img.selectable = true;
img.hoverCursor = 'move';
return this;
};
}
module.exports = Draggable;