Skip to content

Commit 5cf9e20

Browse files
committed
[graphvis] better dragging
SQUASHED: AUTO-COMMIT-doc-files-changesgraph.md,
1 parent 2c6a4df commit 5cf9e20

File tree

1 file changed

+22
-7
lines changed

1 file changed

+22
-7
lines changed

doc/files/changesgraph.md

Lines changed: 22 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -334,18 +334,33 @@ limit <input id="limit"> url <input style="width:500px" id="url" value=""><br>
334334

335335
}
336336

337+
function onPanningDown(evt) {
338+
lastMove = lively.getPosition(evt)
339+
lively.addEventListener("changegraph", document.body.parentElement, "pointermove", evt => onPanningMove(evt))
340+
lively.addEventListener("changegraph", document.body.parentElement, "pointerup", evt => {
341+
lively.removeEventListener("changegraph", document.body.parentElement)
342+
})
343+
evt.stopPropagation()
344+
evt.preventDefault()
345+
}
346+
347+
// always drag with ctrl pressed
337348
pane.addEventListener("pointerdown", evt => {
338349
if (evt.ctrlKey) {
339-
lastMove = lively.getPosition(evt)
340-
lively.addEventListener("changegraph", document.body.parentElement, "pointermove", evt => onPanningMove(evt))
341-
lively.addEventListener("changegraph", document.body.parentElement, "pointerup", evt => {
342-
lively.removeEventListener("changegraph", document.body.parentElement)
343-
})
344-
evt.stopPropagation()
345-
evt.preventDefault()
350+
onPanningDown(evt)
346351
}
347352
}, true)
348353

354+
// but if nothing else... normal drag will do
355+
pane.addEventListener("pointerdown", evt => {
356+
var element = _.first(evt.composedPath())
357+
lively.notify("element " + element.localName)
358+
if (element.localName == "polygon") {
359+
onPanningDown(evt)
360+
}
361+
})
362+
363+
349364
return pane
350365
}
351366
}

0 commit comments

Comments
 (0)