Skip to content

Commit 32a70a6

Browse files
committed
fix(menu): swipe menu is triggered when the swipe |angle| < 40º
1 parent 72c24bc commit 32a70a6

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

src/components/menu/menu-gestures.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ import { SlideData } from '../../gestures/slide-gesture';
44
import { assign } from '../../util/util';
55
import { GestureDelegate, GesturePriority } from '../../gestures/gesture-controller';
66

7+
const DEGRESS_TO_RADIANS = Math.PI / 180;
8+
const MIN_COSINE = Math.cos(40 * DEGRESS_TO_RADIANS);
79

810
/**
911
* Gesture attached to the content which the menu is assigned to
@@ -51,13 +53,13 @@ export class MenuContentGesture extends SlideEdgeGesture {
5153
return true;
5254
}
5355

54-
let cosine = Math.cos(ev.angle * (Math.PI / 180));
56+
let cosine = Math.cos(ev.angle * DEGRESS_TO_RADIANS);
5557
if (menu.side === 'right') {
56-
if (cosine < -0.95) {
58+
if (cosine < -MIN_COSINE) {
5759
return super.canStart(ev);
5860
}
5961
} else {
60-
if (cosine > 0.95) {
62+
if (cosine > MIN_COSINE) {
6163
return super.canStart(ev);
6264
}
6365
}

0 commit comments

Comments
 (0)