@@ -68,6 +68,8 @@ export abstract class MainFrame {
6868 private _showGraphOptions : FRAME_OPTIONS = { } ;
6969 private _theme : Theme ;
7070
71+ private clickFlag = null ;
72+
7173 public constructor ( htmlFrame : HTMLElement , showGraphOptions : FRAME_OPTIONS , theme ?: Theme ) {
7274 this . _htmlFrame = htmlFrame ;
7375
@@ -498,6 +500,29 @@ export abstract class MainFrame {
498500 this . updateNodes ( updates ) ;
499501 }
500502
503+ private _bindNetworkClick ( ) {
504+ let browser : MainFrame = this ;
505+ this . _network . on ( 'click' , function ( args ) {
506+ if ( browser . clickFlag ) { //取消上次延时未执行的方法
507+ browser . clickFlag = clearTimeout ( browser . clickFlag ) ;
508+ }
509+
510+ browser . clickFlag = setTimeout ( function ( ) {
511+ // click 事件的处理
512+ browser . fire ( FrameEventName . NETWORK_CLICK ,
513+ args instanceof CanvasRenderingContext2D ? { context2d : args } : args ) ;
514+ } , 300 ) ; //延时300毫秒执行
515+ } ) ;
516+
517+ this . _network . on ( 'doubleClick' , function ( args ) {
518+ if ( browser . clickFlag ) { //取消上次延时未执行的方法
519+ browser . clickFlag = clearTimeout ( browser . clickFlag ) ;
520+ }
521+ browser . fire ( FrameEventName . NETWORK_DBLCLICK ,
522+ args instanceof CanvasRenderingContext2D ? { context2d : args } : args ) ;
523+ } ) ;
524+ }
525+
501526 private _bindNetworkEvent ( networkEventName , frameEventName ) {
502527 var browser : MainFrame = this ;
503528 this . _network . on ( networkEventName , function ( args ) {
@@ -508,8 +533,8 @@ export abstract class MainFrame {
508533
509534 private _bindNetworkEvents ( ) {
510535 var eventsMap = Utils . toMap ( {
511- "click" : FrameEventName . NETWORK_CLICK ,
512- "doubleClick" : FrameEventName . NETWORK_DBLCLICK ,
536+ // "click": FrameEventName.NETWORK_CLICK,
537+ // "doubleClick": FrameEventName.NETWORK_DBLCLICK,
513538 "oncontext" : FrameEventName . NETWORK_ONCONTEXT ,
514539 "beforeDrawing" : FrameEventName . NETWORK_BEFORE_DRAWING ,
515540 "afterDrawing" : FrameEventName . NETWORK_AFTER_DRAWING ,
@@ -523,6 +548,8 @@ export abstract class MainFrame {
523548 eventsMap . forEach ( ( v , k , map ) => {
524549 this . _bindNetworkEvent ( k , v ) ;
525550 } ) ;
551+
552+ this . _bindNetworkClick ( )
526553 }
527554
528555 private _createEventArgs ( ) : EVENT_ARGS_FRAME {
0 commit comments