Skip to content

Commit

Permalink
fix by Issue jerosoler#292
Browse files Browse the repository at this point in the history
  • Loading branch information
RuslanHimikEvchev committed Nov 10, 2021
1 parent 70f9d98 commit e80c858
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
3 changes: 1 addition & 2 deletions src/drawflow.css
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,13 @@
.drawflow {
width: 100%;
height: 100%;
position: relative;
position: absolute;
user-select: none;

}

.drawflow .parent-node {
position: relative;

}

.drawflow .drawflow-node {
Expand Down
13 changes: 11 additions & 2 deletions src/drawflow.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,8 @@ export default class Drawflow {
// Mobile
this.evCache = new Array();
this.prevDiff = -1;

this.nodesContainer = null;
}

start () {
Expand All @@ -58,6 +60,10 @@ export default class Drawflow {
this.precanvas.classList.add("drawflow");
this.container.appendChild(this.precanvas);

this.nodesContainer = document.createElement('div');
this.nodesContainer.classList.add('drawflow');
this.container.appendChild(this.nodesContainer);

/* Mouse and Touch Actions */
this.container.addEventListener('mouseup', this.dragEnd.bind(this));
this.container.addEventListener('mousemove', this.position.bind(this));
Expand Down Expand Up @@ -346,6 +352,7 @@ export default class Drawflow {
y = this.canvas_y + (-(this.pos_y - e_pos_y))
this.dispatch('translate', { x: x, y: y});
this.precanvas.style.transform = "translate("+x+"px, "+y+"px) scale("+this.zoom+")";
this.nodesContainer.style.transform = "translate("+x+"px, "+y+"px) scale("+this.zoom+")";
}
if(this.drag) {

Expand Down Expand Up @@ -579,6 +586,7 @@ export default class Drawflow {
this.canvas_y = (this.canvas_y / this.zoom_last_value) * this.zoom;
this.zoom_last_value = this.zoom;
this.precanvas.style.transform = "translate("+this.canvas_x+"px, "+this.canvas_y+"px) scale("+this.zoom+")";
this.nodesContainer.style.transform = "translate("+this.canvas_x+"px, "+this.canvas_y+"px) scale("+this.zoom+")";
}
zoom_in() {
if(this.zoom < this.zoom_max) {
Expand Down Expand Up @@ -1281,7 +1289,7 @@ export default class Drawflow {
node.style.top = ele_pos_y + "px";
node.style.left = ele_pos_x + "px";
parent.appendChild(node);
this.precanvas.appendChild(parent);
this.nodesContainer.appendChild(parent);
var json = {
id: newNodeId,
name: name,
Expand Down Expand Up @@ -1314,6 +1322,7 @@ export default class Drawflow {
node.classList.add(dataNode.class);
}


const inputs = document.createElement('div');
inputs.classList.add("inputs");

Expand Down Expand Up @@ -1418,7 +1427,7 @@ export default class Drawflow {
node.style.top = dataNode.pos_y + "px";
node.style.left = dataNode.pos_x + "px";
parent.appendChild(node);
this.precanvas.appendChild(parent);
this.nodesContainer.appendChild(parent);
}

addRerouteImport(dataNode) {
Expand Down

0 comments on commit e80c858

Please sign in to comment.