move the source files to ./src
This commit is contained in:
@@ -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;
|
||||
Reference in New Issue
Block a user