respositionning node (fixed)

graph
Fabien Benetou 2 years ago
parent d7884f0f0c
commit e82e8db66c
  1. 5
      index.html

@ -2102,10 +2102,12 @@ AFRAME.registerComponent('update-links-on-pinchended', {
let rootEl = document.querySelector("#graphroot") let rootEl = document.querySelector("#graphroot")
let el = this.el let el = this.el
this.el.addEventListener('released', function (event) { this.el.addEventListener('released', function (event) {
let found_links = 0
Object.keys( rootEl.components ) // get all links Object.keys( rootEl.components ) // get all links
.filter( i => i.indexOf(el.id) > -1 ) // keeps links related to the moved node .filter( i => i.indexOf(el.id) > -1 ) // keeps links related to the moved node
.map( i => { // for each link .map( i => { // for each link
let newpos = el.getAttribute("position") found_links++
let newpos = AFRAME.utils.coordinates.stringify( el.getAttribute("position") )
let [src,tgt] = i.replace("line__","").split("__to__"); let [src,tgt] = i.replace("line__","").split("__to__");
srcpos = AFRAME.utils.coordinates.stringify( rootEl.getAttribute(i).start ) srcpos = AFRAME.utils.coordinates.stringify( rootEl.getAttribute(i).start )
tgtpos = AFRAME.utils.coordinates.stringify( rootEl.getAttribute(i).end ) tgtpos = AFRAME.utils.coordinates.stringify( rootEl.getAttribute(i).end )
@ -2114,7 +2116,6 @@ AFRAME.registerComponent('update-links-on-pinchended', {
} else { } else {
rootEl.setAttribute(i, { start: srcpos, end: newpos }) rootEl.setAttribute(i, { start: srcpos, end: newpos })
} }
// somehow works once...
}) })
}) })
} }

Loading…
Cancel
Save