.on('end', function () { turnOffCrosshair(selection) // Clear brush var rect = d3BrushSelection(this) if (rect === null) { if (clearingFlag) { clearingFlag = false } else { // Empty selection, deselect all map.select_none() } } else { // Not empty, then clear the box clearingFlag = true selection.call(brush.move, null) } })
.on('brush', function () { const shiftKeyOn = event.sourceEvent.shiftKey const rect = d3BrushSelection(this) // Check for no selection (e.g. after clearing brush) if (rect !== null) { // When shift is pressed, ignore the currently selected nodes. // Otherwise, brush all nodes. var selection = shiftKeyOn ? selectableSelection.selectAll('.node:not(.selected),.text-label:not(.selected)') : selectableSelection.selectAll('.node,.text-label') selection.classed('selected', d => { const sx = d.x const sy = d.y return (rect[0][0] <= sx && sx < rect[1][0] && rect[0][1] <= sy && sy < rect[1][1]) }) } })