its vorkingg....

This commit is contained in:
Connor Turland 2017-02-01 18:08:02 +00:00
parent 6ed9796e05
commit 274b86532a
3 changed files with 15 additions and 9 deletions

View file

@ -108,11 +108,11 @@ export const generateObjectCoordinates = (layoutObject, focalTopicId, focalCoord
// set the focalCoord to be what it already was // set the focalCoord to be what it already was
coords[topic.id] = focalCoords coords[topic.id] = focalCoords
} else if (!parent && !child) { } else if (!parent && !child) {
coords[topic.id] = {x: 0, y: 150} coords[topic.id] = {x: 0, y: 250}
} else if (parent) { } else if (parent) {
coords[topic.id] = { coords[topic.id] = {
x: coords[parent.id].x + 250, x: coords[parent.id].x + 250,
y: coords[parent.id].y y: coords[parent.id].y - (parent.id === focalTopicId ? 250 : 0)
} }
} else if (child) { } else if (child) {
coords[topic.id] = { coords[topic.id] = {

View file

@ -18,8 +18,7 @@ const Engine = {
run: init => { run: init => {
if (init) { if (init) {
if (Active.Mapper && Object.keys(Visualize.mGraph.graph.nodes).length) { if (Active.Mapper && Object.keys(Visualize.mGraph.graph.nodes).length) {
Engine.setFocusNode(Engine.findFocusNode(Visualize.mGraph.graph.nodes)) Engine.setFocusNode(Engine.findFocusNode(Visualize.mGraph.graph.nodes), true)
Engine.runLayout(true)
} }
} }
}, },
@ -56,16 +55,17 @@ const Engine = {
findFocusNode: nodes => { findFocusNode: nodes => {
return last(sortBy(values(nodes), n => new Date(n.getData('topic').get('created_at')))) return last(sortBy(values(nodes), n => new Date(n.getData('topic').get('created_at'))))
}, },
setFocusNode: node => { setFocusNode: (node, init) => {
if (!Active.Mapper) return if (!Active.Mapper) return
Create.newSynapse.focusNode = node Create.newSynapse.focusNode = node
Mouse.focusNodeCoords = node.pos Mouse.focusNodeCoords = node.pos
Mouse.newNodeCoords = { Mouse.newNodeCoords = {
x: node.x + 200, x: node.pos.x + 200,
y: node.y y: node.pos.y
} }
Create.newSynapse.updateForm() Create.newSynapse.updateForm()
Create.newTopic.position() Create.newTopic.position()
Engine.runLayout(init)
}, },
addEdge: edge => { addEdge: edge => {
Engine.runLayout() Engine.runLayout()

View file

@ -5,6 +5,7 @@ import SocketIoConnection from 'simplewebrtc/socketioconnection'
import Active from '../Active' import Active from '../Active'
import Cable from '../Cable' import Cable from '../Cable'
import Create from '../Create'
import DataModel from '../DataModel' import DataModel from '../DataModel'
import JIT from '../JIT' import JIT from '../JIT'
import Util from '../Util' import Util from '../Util'
@ -234,8 +235,13 @@ let Realtime = {
setupLocalEvents: function() { setupLocalEvents: function() {
var self = Realtime var self = Realtime
// local event listeners that trigger events // local event listeners that trigger events
$(document).on(JIT.events.zoom + '.map', self.positionPeerIcons) const panOrZoom = () => {
$(document).on(JIT.events.pan + '.map', self.positionPeerIcons) self.positionPeerIcons()
Create.newSynapse.updateForm()
Create.newTopic.position()
}
$(document).on(JIT.events.zoom + '.map', panOrZoom)
$(document).on(JIT.events.pan + '.map', panOrZoom)
$(document).on('mousemove.map', function(event) { $(document).on('mousemove.map', function(event) {
var pixels = { var pixels = {
x: event.pageX, x: event.pageX,