OLD | NEW |
1 // Copyright 2015 the V8 project authors. All rights reserved. | 1 // Copyright 2015 the V8 project authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 "use strict"; | 5 "use strict"; |
6 | 6 |
7 class GraphView extends View { | 7 class GraphView extends View { |
8 constructor (d3, id, nodes, edges, broker) { | 8 constructor (d3, id, nodes, edges, broker) { |
9 super(id, broker); | 9 super(id, broker); |
10 var graph = this; | 10 var graph = this; |
(...skipping 553 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
564 frontier.each(function(n) { | 564 frontier.each(function(n) { |
565 state.selection.select(this, true); | 565 state.selection.select(this, true); |
566 }); | 566 }); |
567 } | 567 } |
568 graph.updateGraphVisibility(); | 568 graph.updateGraphVisibility(); |
569 } | 569 } |
570 allowRepetition = false; | 570 allowRepetition = false; |
571 } | 571 } |
572 | 572 |
573 var allowRepetition = true; | 573 var allowRepetition = true; |
| 574 var eventHandled = true; // unless the below switch defaults |
574 switch(d3.event.keyCode) { | 575 switch(d3.event.keyCode) { |
575 case 49: | 576 case 49: |
576 case 50: | 577 case 50: |
577 case 51: | 578 case 51: |
578 case 52: | 579 case 52: |
579 case 53: | 580 case 53: |
580 case 54: | 581 case 54: |
581 case 55: | 582 case 55: |
582 case 56: | 583 case 56: |
583 case 57: | 584 case 57: |
(...skipping 25 matching lines...) Expand all Loading... |
609 case 65: | 610 case 65: |
610 // 'a' | 611 // 'a' |
611 graph.selectAllNodes(); | 612 graph.selectAllNodes(); |
612 allowRepetition = false; | 613 allowRepetition = false; |
613 break; | 614 break; |
614 case 38: | 615 case 38: |
615 case 40: { | 616 case 40: { |
616 selectNodesThroughEdges(d3.event.keyCode == 38, undefined, true); | 617 selectNodesThroughEdges(d3.event.keyCode == 38, undefined, true); |
617 break; | 618 break; |
618 } | 619 } |
| 620 default: |
| 621 eventHandled = false; |
| 622 break; |
| 623 } |
| 624 if (eventHandled) { |
| 625 d3.event.preventDefault(); |
619 } | 626 } |
620 if (!allowRepetition) { | 627 if (!allowRepetition) { |
621 state.lastKeyDown = d3.event.keyCode; | 628 state.lastKeyDown = d3.event.keyCode; |
622 } | 629 } |
623 } | 630 } |
624 | 631 |
625 svgKeyUp() { | 632 svgKeyUp() { |
626 this.state.lastKeyDown = -1 | 633 this.state.lastKeyDown = -1 |
627 }; | 634 }; |
628 | 635 |
(...skipping 343 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
972 } | 979 } |
973 | 980 |
974 viewWholeGraph() { | 981 viewWholeGraph() { |
975 var graph = this; | 982 var graph = this; |
976 var minScale = graph.minScale(); | 983 var minScale = graph.minScale(); |
977 var translation = [0, 0]; | 984 var translation = [0, 0]; |
978 translation = graph.getVisibleTranslation(translation, minScale); | 985 translation = graph.getVisibleTranslation(translation, minScale); |
979 graph.translateClipped(translation, minScale); | 986 graph.translateClipped(translation, minScale); |
980 } | 987 } |
981 } | 988 } |
OLD | NEW |