Bug
Pinch event should work.
Importing MatTooltipModule should have no impact on events that are specified in @angular/platform-browser.
pinch events are no longer fired.
https://angular-vcghq7.stackblitz.io/ (use a touch-enabled device to test pinching)
Removing the MatTooltipModule import from app.module.ts makes pinching work again.
At least @angular/material@^7
Seems like the following commit introduced a provider for HAMMER_GESTURE_CONFIG that does not register pinch events: https://github.com/angular/material2/pull/12941/commits/866c1418c6bb5058433acd8225d942e201cf5958
Also, this provider seems to alter the way hammer-js related gestures are interpreted for the complete application.
See https://github.com/angular/material2/blob/master/src/lib/core/gestures/gesture-config.ts
Workaround for this issue is to register a custom HAMMER_GESTURE_CONFIG instance which is based on the material one.
import { GestureConfig, HammerInstance } from '@angular/material';
import * as hammer from 'hammerjs';
/**
* This gesture config adds the missing pinch recognizer to the material GestureConfig.
* See https://github.com/angular/material2/issues/15162
*/
export class PatchedGestureConfig extends GestureConfig {
buildHammer (element: HTMLElement): HammerInstance {
const mc = <HammerManager> super.buildHammer(element);
const pinch = new hammer.Pinch();
mc.add(pinch);
return <HammerInstance> mc;
}
}
Provide it in your module via
import { HAMMER_GESTURE_CONFIG } from '@angular/platform-browser';
.....
providers: [
{
provide: HAMMER_GESTURE_CONFIG,
useClass: PatchedGestureConfig
}
]
No reaction at all? As it is totally unexpected to loose pinch-events when using material tooltips, it should be addressed...
FWIW we plan on removing our use of HammerJS by Angular v9
The exact same behaviour happens when importing
MatSlideToggleModule
just lost 2 hours T_T
Closing since this shouldn't be an issue anymore, because we've stopped using Hammer completely.
This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.
Read more about our automatic conversation locking policy.
_This action has been performed automatically by a bot._
Most helpful comment
The exact same behaviour happens when importing
MatSlideToggleModule
just lost 2 hours T_T