Skip to content
Snippets Groups Projects
Commit 628eca45 authored by Adam Procter's avatar Adam Procter
Browse files

a version of zindex

When you pick up your node will go to the top of the pile, but at 9999 nodes will drop to zero z-index
parent 890720ce
No related branches found
No related tags found
No related merge requests found
...@@ -12,7 +12,7 @@ ...@@ -12,7 +12,7 @@
:y="value.y_pos" :y="value.y_pos"
:z="value.z_index" :z="value.z_index"
:scale="scale" :scale="scale"
@activated="onActivated(nodes.node_id)" @activated="onActivated(nodes.node_id, value.z_index)"
:draggable="false" :draggable="false"
:resizable="false" :resizable="false"
@dragging="onDrag" @dragging="onDrag"
...@@ -90,7 +90,7 @@ ...@@ -90,7 +90,7 @@
:y="value.y_pos" :y="value.y_pos"
:z="value.z_index" :z="value.z_index"
:scale="scale" :scale="scale"
@activated="onActivated(nodes.node_id)" @activated="onActivated(nodes.node_id, value.z_index)"
@dragging="onDrag" @dragging="onDrag"
@resizing="onResize" @resizing="onResize"
@dragstop="onDragstop" @dragstop="onDragstop"
...@@ -200,6 +200,7 @@ export default { ...@@ -200,6 +200,7 @@ export default {
...mapState({ ...mapState({
scale: (state) => state.ui.scale, scale: (state) => state.ui.scale,
myNodes: (state) => state.myNodes, myNodes: (state) => state.myNodes,
configPositions: (state) => state.configPositions, configPositions: (state) => state.configPositions,
configConnections: (state) => state.configConnections, configConnections: (state) => state.configConnections,
configEmoji: (state) => state.configEmoji, configEmoji: (state) => state.configEmoji,
...@@ -266,14 +267,36 @@ export default { ...@@ -266,14 +267,36 @@ export default {
this.$options.positionsArray = this.positions_filtered this.$options.positionsArray = this.positions_filtered
this.$forceUpdate() this.$forceUpdate()
}, },
onActivated(e) { onActivated(id, zindex) {
this.nodeid = e this.zindex = zindex
this.nodeid = id
var i var i
var zindexes = []
for (i = 0; i < Object.keys(this.configPositions).length; i++) {
//console.log(Math.max(...this.configPositions[i].z_index))
zindexes.push(this.configPositions[i].z_index)
if (this.configPositions[i].node_id == this.nodeid) {
this.width = this.configPositions[i].width
this.height = this.configPositions[i].height
this.zindex = this.configPositions[i].z_index
}
// console.log(Math.max(...zindexes))
}
var topZ = Math.max(...zindexes)
for (i = 0; i < Object.keys(this.configPositions).length; i++) { for (i = 0; i < Object.keys(this.configPositions).length; i++) {
if (this.configPositions[i].node_id == this.nodeid) { if (this.configPositions[i].node_id == this.nodeid) {
this.width = this.configPositions[i].width this.width = this.configPositions[i].width
this.height = this.configPositions[i].height this.height = this.configPositions[i].height
if (topZ > 9999) {
this.configPositions[i].z_index = 0
} else {
this.configPositions[i].z_index = topZ + 1
}
} }
// console.log(Math.max(...zindexes))
} }
}, },
onResize(x, y, width, height) { onResize(x, y, width, height) {
...@@ -282,15 +305,15 @@ export default { ...@@ -282,15 +305,15 @@ export default {
this.width = width this.width = width
this.height = height this.height = height
}, },
onResizestop(x, y, width, height, zindex) { onResizestop(x, y, width, height) {
var localnodeid = this.nodeid var localnodeid = this.nodeid
zindex = this.pickupz var zindex
var i var i
for (i = 0; i < Object.keys(this.configPositions).length; i++) { for (i = 0; i < Object.keys(this.configPositions).length; i++) {
if (this.configPositions[i].node_id == this.nodeid) { if (this.configPositions[i].node_id == this.nodeid) {
this.width = this.configPositions[i].width this.width = this.configPositions[i].width
this.height = this.configPositions[i].height this.height = this.configPositions[i].height
this.pickupz = this.configPositions[i].z_index zindex = this.configPositions[i].z_index
} }
} }
this.width = width this.width = width
...@@ -308,9 +331,9 @@ export default { ...@@ -308,9 +331,9 @@ export default {
this.localx = x this.localx = x
this.localy = y this.localy = y
}, },
onDragstop(x, y, width, height, zindex) { onDragstop(x, y, width, height) {
var localnodeid = this.nodeid var localnodeid = this.nodeid
// zindex = this.pickupz var zindex
width = this.width width = this.width
height = this.height height = this.height
var i var i
...@@ -319,7 +342,7 @@ export default { ...@@ -319,7 +342,7 @@ export default {
if (this.configPositions[i].node_id == this.nodeid) { if (this.configPositions[i].node_id == this.nodeid) {
this.localx = this.configPositions[i].x_pos this.localx = this.configPositions[i].x_pos
this.localy = this.configPositions[i].y_pos this.localy = this.configPositions[i].y_pos
this.pickupz = this.configPositions[i].z_index zindex = this.configPositions[i].z_index
} }
} }
this.$store.dispatch('movePos', { this.$store.dispatch('movePos', {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment