Skip to content

Commit

Permalink
Add option to control layer insertion position in addLayer action
Browse files Browse the repository at this point in the history
  • Loading branch information
manisandro committed Oct 24, 2016
1 parent e2ef856 commit d2534e0
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
5 changes: 3 additions & 2 deletions web/client/actions/layers.js
Original file line number Diff line number Diff line change
Expand Up @@ -126,10 +126,11 @@ function layerError(layerId) {
};
}

function addLayer(layer) {
function addLayer(layer, foreground = false) {
return {
type: ADD_LAYER,
layer
layer,
foreground
};
}

Expand Down
3 changes: 2 additions & 1 deletion web/client/reducers/layers.js
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,8 @@ function layers(state = [], action) {
if (groupName !== "background") {
let node = getNode(newGroups, groupName );
if (node) {
newGroups = deepChange(state.groups, groupName, 'nodes', node.nodes.concat(newLayer.id));
let newLayerIds = action.foreground ? [newLayer.id].concat(node.nodes) : node.nodes.concat([newLayer.id]);
newGroups = deepChange(state.groups, groupName, 'nodes', newLayerIds);
} else {
const newGroup = LayersUtils.getLayersByGroup([newLayer]);
newGroups = newGroup.concat(newGroups);
Expand Down

0 comments on commit d2534e0

Please sign in to comment.