dragFirebase = function(simulation) {
function dragstarted(d) {
if (!d3.event.active) simulation.alphaTarget(0.3).restart();
}
function dragged(d) {
d.fx = d3.event.x;
d.fy = d3.event.y;
}
function dragended(d) {
let id = nodeId(d.__proto__);
console.log("d", id, d.fx, d.fy);
let fy = d.fy > height - 50 ? height - 50 : d.fy;
let fx = d.fx > width - 50 ? width - 50 : d.fx;
db.collection("mindmap")
.doc(id)
.update({ x: fx, y: fy, fill: "lightgray" });
d.editing = false;
}
return d3
.drag()
.filter(d => {
return !d3.event.click;
})
.on("start", dragstarted)
.on("drag", dragged)
.on("end", dragended);
}