[Fixed Position] Begin updating controller

Begin updating controller to expose handles for dragging,
resizing elements in fixed position view. WTD-882.
This commit is contained in:
Victor Woeltjen
2015-02-24 10:33:36 -08:00
parent b871e0da91
commit abad8df135
4 changed files with 132 additions and 6 deletions

View File

@ -0,0 +1,52 @@
/*global define*/
define(
[],
function () {
'use strict';
// 8 by 8 pixels
var DRAG_HANDLE_SIZE = [ 8, 8 ];
/**
* Template-displayable drag handle for an element in fixed
* position mode.
* @constructor
*/
function FixedDragHandle(elementHandle, gridSize, commit) {
var self = {};
function getStyle() {
// Adjust from grid to pixel coordinates
var x = elementHandle.x() * gridSize[0],
y = elementHandle.y() * gridSize[1];
// Convert to a CSS style centered on that point
return {
left: (x - DRAG_HANDLE_SIZE[0] / 2) + 'px',
right: (x - DRAG_HANDLE_SIZE[1] / 2) + 'px',
width: DRAG_HANDLE_SIZE[0] + 'px',
height: DRAG_HANDLE_SIZE[1] + 'px'
};
}
function noop() {
}
return {
/**
* Get a CSS style to position this drag handle.
* @returns CSS style object (for `ng-style`)
*/
style: getStyle,
startDrag: noop,
continueDrag: noop,
endDrag: noop
};
}
return FixedDragHandle;
}
);