本文整理汇总了TypeScript中d3.event类的典型用法代码示例。如果您正苦于以下问题:TypeScript event类的具体用法?TypeScript event怎么用?TypeScript event使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了event类的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: function
.on("click", function (edge) {
d3.event.stopPropagation();
if (!d3.event.shiftKey) {
view.selectionHandler.clear();
}
view.selectionHandler.select([edge.source, edge.target], true);
})
示例2: function
.on("click", function (d) {
var components = this.id.split(',');
var node = graph.nodeMap[components[3]];
var edge = node.inputs[components[2]];
var visible = !edge.isVisible();
node.setInputVisibility(components[2], visible);
d3.event.stopPropagation();
graph.updateGraphVisibility();
});
示例3: started
function started() {
/** Preventing propagation of dragstart to parent elements */
d3.event.sourceEvent.stopPropagation();
if (!d3.event.active) {
graph.simulation.alphaTarget(0.3).restart();
}
d3.event.on('drag', dragged).on('end', ended);
function dragged() {
node.fx = d3.event.x;
node.fy = d3.event.y;
}
function ended() {
if (!d3.event.active) {
graph.simulation.alphaTarget(0);
}
node.fx = null;
node.fy = null;
}
}
示例4:
.on("click", d => {
if (!d3.event.shiftKey) view.selectionHandler.clear();
view.selectionHandler.select([d], undefined);
d3.event.stopPropagation();
})
示例5: svgKeyDown
svgKeyDown() {
const view = this;
const state = this.state;
const showSelectionFrontierNodes = (inEdges: boolean, filter: (e: Edge, i: number) => boolean, doSelect: boolean) => {
const frontier = view.getNodeFrontier(state.selection, inEdges, filter);
if (frontier != undefined && frontier.size) {
if (doSelect) {
if (!d3.event.shiftKey) {
state.selection.clear();
}
state.selection.select([...frontier], true);
}
view.updateGraphVisibility();
}
};
let eventHandled = true; // unless the below switch defaults
switch (d3.event.keyCode) {
case 49:
case 50:
case 51:
case 52:
case 53:
case 54:
case 55:
case 56:
case 57:
// '1'-'9'
showSelectionFrontierNodes(true,
(edge: Edge, index: number) => index == (d3.event.keyCode - 49),
!d3.event.ctrlKey);
break;
case 97:
case 98:
case 99:
case 100:
case 101:
case 102:
case 103:
case 104:
case 105:
// 'numpad 1'-'numpad 9'
showSelectionFrontierNodes(true,
(edge, index) => index == (d3.event.keyCode - 97),
!d3.event.ctrlKey);
break;
case 67:
// 'c'
showSelectionFrontierNodes(d3.event.altKey,
(edge, index) => edge.type == 'control',
true);
break;
case 69:
// 'e'
showSelectionFrontierNodes(d3.event.altKey,
(edge, index) => edge.type == 'effect',
true);
break;
case 79:
// 'o'
showSelectionFrontierNodes(false, undefined, false);
break;
case 73:
// 'i'
if (!d3.event.ctrlKey && !d3.event.shiftKey) {
showSelectionFrontierNodes(true, undefined, false);
} else {
eventHandled = false;
}
break;
case 65:
// 'a'
view.selectAllNodes();
break;
case 38:
// UP
case 40: {
// DOWN
showSelectionFrontierNodes(d3.event.keyCode == 38, undefined, true);
break;
}
case 82:
// 'r'
if (!d3.event.ctrlKey && !d3.event.shiftKey) {
this.layoutAction(this);
} else {
eventHandled = false;
}
break;
case 83:
// 's'
view.selectOrigins();
break;
default:
eventHandled = false;
break;
}
if (eventHandled) {
d3.event.preventDefault();
//.........这里部分代码省略.........
示例6:
.on("click", (d) => {
if (!d3.event.shiftKey) graph.selectionHandler.clear();
graph.selectionHandler.select([d], undefined);
d3.event.stopPropagation();
})
示例7: svgKeyDown
svgKeyDown() {
var state = this.state;
var graph = this;
// Don't handle key press repetition
if (state.lastKeyDown !== -1) return;
var showSelectionFrontierNodes = function (inEdges, filter, select) {
var frontier = graph.getNodeFrontier(state.selection, inEdges, filter);
if (frontier != undefined && frontier.size) {
if (select) {
if (!d3.event.shiftKey) {
state.selection.clear();
}
state.selection.select(frontier, true);
}
graph.updateGraphVisibility();
}
allowRepetition = false;
}
var allowRepetition = true;
var eventHandled = true; // unless the below switch defaults
switch (d3.event.keyCode) {
case 49:
case 50:
case 51:
case 52:
case 53:
case 54:
case 55:
case 56:
case 57:
// '1'-'9'
showSelectionFrontierNodes(true,
(edge, index) => { return index == (d3.event.keyCode - 49); },
false);
break;
case 97:
case 98:
case 99:
case 100:
case 101:
case 102:
case 103:
case 104:
case 105:
// 'numpad 1'-'numpad 9'
showSelectionFrontierNodes(true,
(edge, index) => { return index == (d3.event.keyCode - 97); },
false);
break;
case 67:
// 'c'
showSelectionFrontierNodes(d3.event.altKey,
(edge, index) => { return edge.type == 'control'; },
true);
break;
case 69:
// 'e'
showSelectionFrontierNodes(d3.event.altKey,
(edge, index) => { return edge.type == 'effect'; },
true);
break;
case 79:
// 'o'
showSelectionFrontierNodes(false, undefined, false);
break;
case 73:
// 'i'
showSelectionFrontierNodes(true, undefined, false);
break;
case 65:
// 'a'
graph.selectAllNodes();
allowRepetition = false;
break;
case 38:
case 40: {
showSelectionFrontierNodes(d3.event.keyCode == 38, undefined, true);
break;
}
case 82:
// 'r'
if (!d3.event.ctrlKey) {
this.layoutAction(this);
} else {
eventHandled = false;
}
break;
case 83:
// 's'
graph.selectOrigins();
break;
case 191:
// '/'
document.getElementById("search-input").focus();
break;
default:
eventHandled = false;
//.........这里部分代码省略.........
示例8:
return connection => {
connection.onSelectedListener(connection);
d3.event.stopPropagation();
};