mirror of
https://github.com/nasa/openmct.git
synced 2024-12-24 15:26:39 +00:00
[Fixed Position] Allow dragging of elements
Restore dragging behavior to elements in a fixed position view, WTD-879.
This commit is contained in:
parent
5680710c06
commit
7bd41a9f80
@ -17,15 +17,9 @@
|
|||||||
ng-class="{ test: controller.selected(element) }"
|
ng-class="{ test: controller.selected(element) }"
|
||||||
ng-style="element.style"
|
ng-style="element.style"
|
||||||
ng-click="controller.select(element)"
|
ng-click="controller.select(element)"
|
||||||
ng-model="element">
|
ng-model="element"
|
||||||
</mct-include>
|
mct-drag-down="controller.startDrag(element); controller.select(element)"
|
||||||
|
mct-drag="controller.continueDrag(delta)"
|
||||||
<!-- Drag handles -->
|
|
||||||
<span ng-show="false && domainObject.hasCapability('editor')">
|
|
||||||
<span style="position: absolute; left: 0px; right: 0px; top: 0px; bottom: 0px; cursor: move;"
|
|
||||||
mct-drag-down="controller.startDrag(element, [1,1], [0,0])"
|
|
||||||
mct-drag="controller.continueDrag(element)"
|
|
||||||
mct-drag-up="controller.endDrag()">
|
mct-drag-up="controller.endDrag()">
|
||||||
</span>
|
</mct-include>
|
||||||
</span>
|
|
||||||
</div>
|
</div>
|
@ -20,6 +20,7 @@ define(
|
|||||||
function FixedController($scope, telemetrySubscriber, telemetryFormatter) {
|
function FixedController($scope, telemetrySubscriber, telemetryFormatter) {
|
||||||
var gridSize = DEFAULT_GRID_SIZE,
|
var gridSize = DEFAULT_GRID_SIZE,
|
||||||
gridExtent = DEFAULT_GRID_EXTENT,
|
gridExtent = DEFAULT_GRID_EXTENT,
|
||||||
|
dragging,
|
||||||
subscription,
|
subscription,
|
||||||
cellStyles = [],
|
cellStyles = [],
|
||||||
elementProxies = [],
|
elementProxies = [],
|
||||||
@ -265,20 +266,18 @@ define(
|
|||||||
* with the mouse while the horizontal dimensions shrink in
|
* with the mouse while the horizontal dimensions shrink in
|
||||||
* kind (and vertical properties remain unmodified.)
|
* kind (and vertical properties remain unmodified.)
|
||||||
*
|
*
|
||||||
* @param {string} id the identifier of the domain object
|
* @param element the raw (undecorated) element to drag
|
||||||
* in the frame being manipulated
|
|
||||||
* @param {number[]} posFactor the position factor
|
|
||||||
* @param {number[]} dimFactor the dimensions factor
|
|
||||||
*/
|
*/
|
||||||
startDrag: function (id, posFactor, dimFactor) {
|
startDrag: function (element) {
|
||||||
// TODO: Drag!
|
// Only allow dragging in edit mode
|
||||||
// activeDragId = id;
|
if ($scope.domainObject &&
|
||||||
// activeDrag = new LayoutDrag(
|
$scope.domainObject.hasCapability('editor')) {
|
||||||
// rawPositions[id],
|
dragging = {
|
||||||
// posFactor,
|
element: element,
|
||||||
// dimFactor,
|
x: element.x(),
|
||||||
// gridSize
|
y: element.y()
|
||||||
// );
|
};
|
||||||
|
}
|
||||||
},
|
},
|
||||||
/**
|
/**
|
||||||
* Continue an active drag gesture.
|
* Continue an active drag gesture.
|
||||||
@ -287,34 +286,22 @@ define(
|
|||||||
* to its position when the drag started
|
* to its position when the drag started
|
||||||
*/
|
*/
|
||||||
continueDrag: function (delta) {
|
continueDrag: function (delta) {
|
||||||
// TODO: Drag!
|
if (dragging) {
|
||||||
// if (activeDrag) {
|
dragging.element.x(dragging.x + Math.round(delta[0] / gridSize[0]));
|
||||||
// rawPositions[activeDragId] =
|
dragging.element.y(dragging.y + Math.round(delta[1] / gridSize[1]));
|
||||||
// activeDrag.getAdjustedPosition(delta);
|
dragging.element.style = convertPosition(dragging.element.element);
|
||||||
// populatePosition(activeDragId);
|
}
|
||||||
// }
|
|
||||||
},
|
},
|
||||||
/**
|
/**
|
||||||
* End the active drag gesture. This will update the
|
* End the active drag gesture. This will update the
|
||||||
* view configuration.
|
* view configuration.
|
||||||
*/
|
*/
|
||||||
endDrag: function () {
|
endDrag: function () {
|
||||||
// TODO: Drag!
|
// Mark this object as dirty to encourage persistence
|
||||||
// // Write to configuration; this is watched and
|
if (dragging && $scope.commit) {
|
||||||
// // saved by the EditRepresenter.
|
dragging = undefined;
|
||||||
// $scope.configuration =
|
$scope.commit("Moved element.");
|
||||||
// $scope.configuration || {};
|
}
|
||||||
// // Make sure there is a "panels" field in the
|
|
||||||
// // view configuration.
|
|
||||||
// $scope.configuration.elements =
|
|
||||||
// $scope.configuration.elements || {};
|
|
||||||
// // Store the position of this panel.
|
|
||||||
// $scope.configuration.elements[activeDragId] =
|
|
||||||
// rawPositions[activeDragId];
|
|
||||||
// // Mark this object as dirty to encourage persistence
|
|
||||||
// if ($scope.commit) {
|
|
||||||
// $scope.commit("Moved element.");
|
|
||||||
// }
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -17,7 +17,7 @@ define(
|
|||||||
if (arguments.length > 0) {
|
if (arguments.length > 0) {
|
||||||
object[key] = value;
|
object[key] = value;
|
||||||
}
|
}
|
||||||
return value;
|
return object[key];
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user