@@ -180,6 +180,7 @@ export class Stencil extends View implements Graph.Plugin {
180
180
)
181
181
groupNames . forEach ( ( groupName ) => {
182
182
const graph = this . graphs [ groupName ]
183
+ this . unregisterGraphEvents ( graph )
183
184
graph . dispose ( )
184
185
delete this . graphs [ groupName ]
185
186
@@ -249,6 +250,8 @@ export class Stencil extends View implements Graph.Plugin {
249
250
preventDefaultBlankAction : false ,
250
251
} )
251
252
253
+ this . registerGraphEvents ( graph )
254
+
252
255
Dom . append ( content , graph . container )
253
256
Dom . append ( groupElem , [ title , content ] )
254
257
Dom . appendTo ( groupElem , this . content )
@@ -339,19 +342,18 @@ export class Stencil extends View implements Graph.Plugin {
339
342
[ `focusin .${ searchText } ` ] : 'onSearchFocusIn' ,
340
343
[ `focusout .${ searchText } ` ] : 'onSearchFocusOut' ,
341
344
} )
342
-
343
- Object . keys ( this . graphs ) . forEach ( ( groupName ) => {
344
- const graph = this . graphs [ groupName ]
345
- graph . on ( 'cell:mousedown' , this . onDragStart , this )
346
- } )
347
345
}
348
346
349
347
protected stopListening ( ) {
350
348
this . undelegateEvents ( )
351
- Object . keys ( this . graphs ) . forEach ( ( groupName ) => {
352
- const graph = this . graphs [ groupName ]
353
- graph . off ( 'cell:mousedown' , this . onDragStart , this )
354
- } )
349
+ }
350
+
351
+ protected registerGraphEvents ( graph : Graph ) {
352
+ graph . on ( 'cell:mousedown' , this . onDragStart , this )
353
+ }
354
+
355
+ protected unregisterGraphEvents ( graph : Graph ) {
356
+ graph . off ( 'cell:mousedown' , this . onDragStart , this )
355
357
}
356
358
357
359
protected loadGroup (
@@ -571,6 +573,7 @@ export class Stencil extends View implements Graph.Plugin {
571
573
protected clearGroups ( ) {
572
574
Object . keys ( this . graphs ) . forEach ( ( groupName ) => {
573
575
const graph = this . graphs [ groupName ]
576
+ this . unregisterGraphEvents ( graph )
574
577
graph . dispose ( )
575
578
} )
576
579
Object . keys ( this . groups ) . forEach ( ( groupName ) => {
0 commit comments