diff --git a/packages/platform-browser/src/dom/events/hammer_gestures.ts b/packages/platform-browser/src/dom/events/hammer_gestures.ts index 7e2a5db227..d6136ff8a1 100644 --- a/packages/platform-browser/src/dom/events/hammer_gestures.ts +++ b/packages/platform-browser/src/dom/events/hammer_gestures.ts @@ -71,6 +71,7 @@ export const HAMMER_LOADER = new InjectionToken('HammerLoader'); export interface HammerInstance { on(eventName: string, callback?: Function): void; off(eventName: string, callback?: Function): void; + destroy?(): void; } /** @@ -214,7 +215,13 @@ export class HammerGesturesPlugin extends EventManagerPlugin { zone.runGuarded(function() { handler(eventObj); }); }; mc.on(eventName, callback); - return () => mc.off(eventName, callback); + return () => { + mc.off(eventName, callback); + // destroy mc to prevent memory leak + if (typeof mc.destroy === 'function') { + mc.destroy(); + } + }; }); }