File tree Expand file tree Collapse file tree 1 file changed +8
-1
lines changed
packages/platform-browser/src/dom/events Expand file tree Collapse file tree 1 file changed +8
-1
lines changed Original file line number Diff line number Diff line change @@ -71,6 +71,7 @@ export const HAMMER_LOADER = new InjectionToken<HammerLoader>('HammerLoader');
71
71
export interface HammerInstance {
72
72
on ( eventName : string , callback ?: Function ) : void ;
73
73
off ( eventName : string , callback ?: Function ) : void ;
74
+ destroy ?( ) : void ;
74
75
}
75
76
76
77
/**
@@ -214,7 +215,13 @@ export class HammerGesturesPlugin extends EventManagerPlugin {
214
215
zone . runGuarded ( function ( ) { handler ( eventObj ) ; } ) ;
215
216
} ;
216
217
mc . on ( eventName , callback ) ;
217
- return ( ) => mc . off ( eventName , callback ) ;
218
+ return ( ) => {
219
+ mc . off ( eventName , callback ) ;
220
+ // destroy mc to prevent memory leak
221
+ if ( typeof mc . destroy === 'function' ) {
222
+ mc . destroy ( ) ;
223
+ }
224
+ } ;
218
225
} ) ;
219
226
}
220
227
You can’t perform that action at this time.
0 commit comments