From 890720ce7410085546e82fc82a40bf51b672561f Mon Sep 17 00:00:00 2001 From: Adam Procter <adamprocter@researchnot.es> Date: Thu, 10 Dec 2020 18:34:29 +0000 Subject: [PATCH] z-index part 1 create node with z-index higher than all other nodes in current microcosm --- app/src/components/NodesLayer.vue | 2 +- app/src/store/index.js | 10 ++++++---- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/app/src/components/NodesLayer.vue b/app/src/components/NodesLayer.vue index e870a08..bb1bd55 100644 --- a/app/src/components/NodesLayer.vue +++ b/app/src/components/NodesLayer.vue @@ -310,7 +310,7 @@ export default { }, onDragstop(x, y, width, height, zindex) { var localnodeid = this.nodeid - zindex = this.pickupz + // zindex = this.pickupz width = this.width height = this.height var i diff --git a/app/src/store/index.js b/app/src/store/index.js index e36ca6d..04f1fc5 100644 --- a/app/src/store/index.js +++ b/app/src/store/index.js @@ -392,6 +392,8 @@ const store = new Vuex.Store({ ADD_NODE(state) { var i + var totalNodes = [] + const reducer = (accumulator, currentValue) => accumulator + currentValue for (i = 0; i < Object.keys(state.allNodes).length; i++) { if ( state.allNodes[i].id != state.global_pos_name && @@ -399,12 +401,12 @@ const store = new Vuex.Store({ state.allNodes[i].id != state.global_con_name //&& // ) { - // each loop gets the array - // add them each loop - var j = state.allNodes[i].doc.nodes.length + // console.log(state.allNodes[i].doc.nodes.length) + totalNodes.push(state.allNodes[i].doc.nodes.length) } } + var zindex = totalNodes.reduce(reducer) var uniqueid = Math.random().toString(36).substring(2, 15) + Math.random().toString(36).substring(2, 15) @@ -475,7 +477,7 @@ const store = new Vuex.Store({ y_pos: localypos, width: 200, height: 370, - z_index: 10, + z_index: zindex, read_mode: false, }) return pouchdb -- GitLab