mirror of
https://github.com/nasa/openmct.git
synced 2025-05-09 12:03:21 +00:00
[Layout] Position frames on drop
Position frames within a layout based on the position where they were dropped into the layout, WTD-877.
This commit is contained in:
parent
e158f2811c
commit
01d953bf45
@ -85,6 +85,26 @@ define(
|
|||||||
// Position panes when the model field changes
|
// Position panes when the model field changes
|
||||||
$scope.$watch("model.composition", lookupPanels);
|
$scope.$watch("model.composition", lookupPanels);
|
||||||
|
|
||||||
|
// Position panes where they are dropped
|
||||||
|
$scope.$on("mctDrop", function (e, id, position) {
|
||||||
|
// Make sure there is a "panels" field in the
|
||||||
|
// view configuration.
|
||||||
|
$scope.configuration.panels =
|
||||||
|
$scope.configuration.panels || {};
|
||||||
|
// Store the position of this panel.
|
||||||
|
$scope.configuration.panels[id] = {
|
||||||
|
position: [
|
||||||
|
Math.floor(position.x / gridSize[0]),
|
||||||
|
Math.floor(position.y / gridSize[1])
|
||||||
|
],
|
||||||
|
dimensions: DEFAULT_DIMENSIONS
|
||||||
|
};
|
||||||
|
// Mark change as persistable
|
||||||
|
if ($scope.commit) {
|
||||||
|
$scope.commit("Dropped a frame.");
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
return {
|
return {
|
||||||
/**
|
/**
|
||||||
* Get a style object for a frame with the specified domain
|
* Get a style object for a frame with the specified domain
|
||||||
|
@ -22,14 +22,23 @@ define(
|
|||||||
function DropGesture($q, element, domainObject) {
|
function DropGesture($q, element, domainObject) {
|
||||||
function broadcastDrop(id, event) {
|
function broadcastDrop(id, event) {
|
||||||
// Find the relevant scope...
|
// Find the relevant scope...
|
||||||
var scope = element && element.scope && element.scope();
|
var scope = element && element.scope && element.scope(),
|
||||||
|
rect;
|
||||||
if (scope && scope.$broadcast) {
|
if (scope && scope.$broadcast) {
|
||||||
|
// Get the representation's bounds, to convert
|
||||||
|
// drop position
|
||||||
|
rect = element[0].getBoundingClientRect();
|
||||||
|
|
||||||
// ...and broadcast the event. This allows specific
|
// ...and broadcast the event. This allows specific
|
||||||
// views to have post-drop behavior which depends on
|
// views to have post-drop behavior which depends on
|
||||||
// drop position.
|
// drop position.
|
||||||
scope.$broadcast(
|
scope.$broadcast(
|
||||||
GestureConstants.MCT_DROP_EVENT,
|
GestureConstants.MCT_DROP_EVENT,
|
||||||
{ id: id, dropEvent: event }
|
id,
|
||||||
|
{
|
||||||
|
x: event.pageX - rect.left,
|
||||||
|
y: event.pageY - rect.top
|
||||||
|
}
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user