Created
January 22, 2020 14:55
-
-
Save gannebamm/6b067ff067a58d21b7bb17c6211d5390 to your computer and use it in GitHub Desktop.
mutally exclusive layers in group with title 'exclusive'
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// LINE 146 | |
case CHANGE_LAYER_PROPERTIES: { | |
const flatLayers = (state.flat || []); | |
let isBackground = flatLayers.reduce( | |
(background, layer) => background || (layer.id === action.layer && layer.group === 'background'), | |
false); | |
const newLayers = flatLayers.map((layer) => { | |
if ( includes(castArray(action.layer), layer.id )) { | |
return assign( | |
{}, | |
layer, | |
action.newProperties, | |
action.params | |
? { | |
params: assign({}, layer.params, action.params) | |
} | |
: {}); | |
} else if (layer.group === 'background' && isBackground && action.newProperties && action.newProperties.visibility) { | |
// TODO remove | |
return assign({}, layer, {visibility: false}); | |
} | |
// check if layer shall be exclusive | |
const groups = (state.groups); | |
for (let i in groups) { | |
const group = groups[i]; | |
if (group.id === layer.group) { | |
// get group of layer | |
if (group.title === 'exclusive') { | |
if (action.newProperties && action.newProperties.visibility) { | |
console.log(layer.title + " should not be visible anymore"); | |
return assign({}, layer, {visibility: false}); | |
} | |
} | |
} | |
} | |
return assign({}, layer); | |
}); | |
return assign({}, state, {flat: newLayers}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment